Commit 6ac319a0 authored by Evan Stade's avatar Evan Stade Committed by Commit Bot

Restore default large icon for Android MediaSession notifications.

Regressed in 7bb74836 due to an inverted
condition.

Bug: 1098217
Change-Id: I7e5cc46994e7df4ac66a1bbc2681af679d1ce736
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2283938Reviewed-by: default avatarMounir Lamouri <mlamouri@chromium.org>
Commit-Queue: Evan Stade <estade@chromium.org>
Cr-Commit-Position: refs/heads/master@{#786339}
parent 47c1909f
......@@ -6,6 +6,7 @@ package org.chromium.chrome.browser.media.ui;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotEquals;
import static org.junit.Assert.assertTrue;
import static org.mockito.Mockito.any;
import static org.mockito.Mockito.doCallRealMethod;
......@@ -28,6 +29,7 @@ import org.chromium.chrome.R;
import org.chromium.chrome.browser.media.ui.ChromeMediaNotificationControllerDelegate.ListenerService;
import org.chromium.chrome.browser.ui.favicon.IconType;
import org.chromium.chrome.browser.ui.favicon.LargeIconBridge;
import org.chromium.components.browser_ui.media.MediaNotificationInfo;
/**
* Test of media notifications to ensure that the favicon is displayed on normal devices and
......@@ -155,10 +157,31 @@ public class MediaNotificationFaviconTest extends MediaNotificationTestBase {
assertEquals(mFavicon, getDisplayedIcon());
}
@Test
public void testWillReturnLargeIcon() {
mTabHolder.simulateFaviconUpdated(mFavicon);
mTabHolder.mMediaSessionTabHelper.mLargeIconBridge = new TestLargeIconBridge();
mTabHolder.simulateMediaSessionStateChanged(true, false);
assertEquals(0, getCurrentNotificationInfo().defaultNotificationLargeIcon);
}
@Test
public void testNoLargeIcon() {
mTabHolder.simulateFaviconUpdated(null);
mTabHolder.simulateMediaSessionStateChanged(true, false);
assertNotEquals(0, getCurrentNotificationInfo().defaultNotificationLargeIcon);
}
private Bitmap getDisplayedIcon() {
return mTabHolder.mMediaSessionTabHelper.mMediaSessionHelper.mFavicon;
}
private MediaNotificationInfo getCurrentNotificationInfo() {
return mTabHolder.mMediaSessionTabHelper.mMediaSessionHelper.mNotificationInfoBuilder
.build();
}
@Override
int getNotificationId() {
return R.id.media_playback_notification;
......
......@@ -56,7 +56,8 @@ public class MediaSessionHelper implements MediaImageCallback {
private Bitmap mCurrentMediaImage;
private String mOrigin;
private int mPreviousVolumeControlStream = AudioManager.USE_DEFAULT_STREAM_TYPE;
private MediaNotificationInfo.Builder mNotificationInfoBuilder;
@VisibleForTesting
public MediaNotificationInfo.Builder mNotificationInfoBuilder;
// The fallback title if |mPageMetadata| is null or its title is empty.
private String mFallbackTitle;
// Set to true if favicon update callback was called at least once.
......@@ -225,7 +226,7 @@ public class MediaSessionHelper implements MediaImageCallback {
// delegate will pass a favicon later, show nothing for now; we expect the favicon
// to arrive quickly.
if (mWebContents.isIncognito()
|| (mCurrentMediaImage == null && fetchLargeFaviconImage())) {
|| (mCurrentMediaImage == null && !fetchLargeFaviconImage())) {
mNotificationInfoBuilder.setDefaultNotificationLargeIcon(
R.drawable.audio_playing_square);
}
......
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