Commit 63b65fd1 authored by dgn's avatar dgn Committed by Commit bot

Add unit tests for media.remote.AbstractMediaRouteController

BUG=472067

Review URL: https://codereview.chromium.org/1066863004

Cr-Commit-Position: refs/heads/master@{#327254}
parent b773100e
...@@ -463,6 +463,7 @@ android_apk("chrome_shell_test_apk") { ...@@ -463,6 +463,7 @@ android_apk("chrome_shell_test_apk") {
junit_binary("chrome_junit_tests") { junit_binary("chrome_junit_tests") {
java_files = [ java_files = [
"junit/src/org/chromium/chrome/browser/omaha/ResponseParserTest.java", "junit/src/org/chromium/chrome/browser/omaha/ResponseParserTest.java",
"junit/src/org/chromium/chrome/browser/media/remote/AbstractMediaRouteControllerTest.java",
"junit/src/org/chromium/chrome/browser/media/remote/MediaUrlResolverTest.java", "junit/src/org/chromium/chrome/browser/media/remote/MediaUrlResolverTest.java",
"junit/src/org/chromium/chrome/browser/media/remote/RemoteVideoInfoTest.java", "junit/src/org/chromium/chrome/browser/media/remote/RemoteVideoInfoTest.java",
"junit/src/org/chromium/chrome/browser/media/remote/TransportControlTest.java", "junit/src/org/chromium/chrome/browser/media/remote/TransportControlTest.java",
...@@ -472,6 +473,7 @@ junit_binary("chrome_junit_tests") { ...@@ -472,6 +473,7 @@ junit_binary("chrome_junit_tests") {
"//base:base_java", "//base:base_java",
"//base:base_java_test_support", "//base:base_java_test_support",
"//third_party/junit:hamcrest", "//third_party/junit:hamcrest",
"//third_party/android_tools:android_support_v7_mediarouter_java",
] ]
} }
......
...@@ -20,6 +20,7 @@ import com.google.android.gms.cast.CastMediaControlIntent; ...@@ -20,6 +20,7 @@ import com.google.android.gms.cast.CastMediaControlIntent;
import org.chromium.base.ApplicationStatus; import org.chromium.base.ApplicationStatus;
import org.chromium.base.CommandLine; import org.chromium.base.CommandLine;
import org.chromium.base.VisibleForTesting;
import org.chromium.chrome.ChromeSwitches; import org.chromium.chrome.ChromeSwitches;
import org.chromium.chrome.R; import org.chromium.chrome.R;
import org.chromium.chrome.browser.media.remote.RemoteVideoInfo.PlayerState; import org.chromium.chrome.browser.media.remote.RemoteVideoInfo.PlayerState;
...@@ -485,13 +486,8 @@ public abstract class AbstractMediaRouteController implements MediaRouteControll ...@@ -485,13 +486,8 @@ public abstract class AbstractMediaRouteController implements MediaRouteControll
} }
} }
protected void updateState(int state) { @VisibleForTesting
if (mDebug) { void setPlayerStateForMediaItemState(int state) {
Log.d(TAG, "updateState oldState: " + this.mPlaybackState + " newState: " + state);
}
PlayerState oldState = this.mPlaybackState;
PlayerState playerState = PlayerState.STOPPED; PlayerState playerState = PlayerState.STOPPED;
switch (state) { switch (state) {
case MediaItemStatus.PLAYBACK_STATE_BUFFERING: case MediaItemStatus.PLAYBACK_STATE_BUFFERING:
...@@ -526,13 +522,22 @@ public abstract class AbstractMediaRouteController implements MediaRouteControll ...@@ -526,13 +522,22 @@ public abstract class AbstractMediaRouteController implements MediaRouteControll
break; break;
} }
this.mPlaybackState = playerState; mPlaybackState = playerState;
}
protected void updateState(int state) {
if (mDebug) {
Log.d(TAG, "updateState oldState: " + mPlaybackState + " newState: " + state);
}
PlayerState oldState = mPlaybackState;
setPlayerStateForMediaItemState(state);
for (UiListener listener : mUiListeners) { for (UiListener listener : mUiListeners) {
listener.onPlaybackStateChanged(oldState, playerState); listener.onPlaybackStateChanged(oldState, mPlaybackState);
} }
if (mMediaStateListener != null) mMediaStateListener.onPlaybackStateChanged(playerState); if (mMediaStateListener != null) mMediaStateListener.onPlaybackStateChanged(mPlaybackState);
if (oldState != mPlaybackState) { if (oldState != mPlaybackState) {
// We need to persist our state in case we get killed. // We need to persist our state in case we get killed.
......
...@@ -290,13 +290,13 @@ public interface MediaRouteController extends TransportControl.Listener { ...@@ -290,13 +290,13 @@ public interface MediaRouteController extends TransportControl.Listener {
public PlayerState getPlayerState(); public PlayerState getPlayerState();
/** /**
* Add a media state listener * Remove an existing media state listener
* @param listener * @param listener
*/ */
public void removeMediaStateListener(MediaStateListener listener); public void removeMediaStateListener(MediaStateListener listener);
/** /**
* Remove an existing media state listener * Add a media state listener
* @param listener * @param listener
*/ */
public void addMediaStateListener(MediaStateListener listener); public void addMediaStateListener(MediaStateListener listener);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment