Commit e8af7273 authored by Theresa Wellington's avatar Theresa Wellington Committed by Commit Bot

Reset menu button background when removing IPH highlight

Previously the menu button background was set to null when removing the
IPH pulse highlighting. Instead, set back to the original background.

BUG=1134646

Change-Id: Ie4639be34175cf737154b877cb44e29acc74ef5c
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2487680Reviewed-by: default avatarPatrick Noland <pnoland@chromium.org>
Commit-Queue: Theresa  <twellington@chromium.org>
Auto-Submit: Theresa  <twellington@chromium.org>
Cr-Commit-Position: refs/heads/master@{#819083}
parent 4c6a6f53
......@@ -51,6 +51,7 @@ public class MenuButton extends FrameLayout implements TintObserver {
private boolean mHighlightingMenu;
private PulseDrawable mHighlightDrawable;
private Drawable mOriginalBackground;
private AnimatorSet mMenuBadgeAnimatorSet;
private boolean mIsMenuBadgeAnimationRunning;
......@@ -68,6 +69,7 @@ public class MenuButton extends FrameLayout implements TintObserver {
super.onFinishInflate();
mMenuImageButton = findViewById(R.id.menu_button);
mUpdateBadgeView = findViewById(R.id.menu_badge);
mOriginalBackground = getBackground();
}
public void setAppMenuButtonHelper(AppMenuButtonHelper appMenuButtonHelper) {
......@@ -255,7 +257,7 @@ public class MenuButton extends FrameLayout implements TintObserver {
setBackground(mHighlightDrawable);
mHighlightDrawable.start();
} else {
setBackground(null);
setBackground(mOriginalBackground);
}
}
......@@ -384,4 +386,10 @@ public class MenuButton extends FrameLayout implements TintObserver {
return set;
}
@VisibleForTesting
void setOriginalBackgroundForTesting(Drawable background) {
mOriginalBackground = background;
setBackground(mOriginalBackground);
}
}
......@@ -16,11 +16,14 @@ import android.content.res.ColorStateList;
import android.graphics.Bitmap;
import android.graphics.Rect;
import android.graphics.drawable.BitmapDrawable;
import android.graphics.drawable.ColorDrawable;
import android.graphics.drawable.Drawable;
import android.view.LayoutInflater;
import android.view.View.MeasureSpec;
import android.view.ViewGroup;
import android.widget.LinearLayout;
import org.junit.Assert;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
......@@ -134,4 +137,19 @@ public class MenuButtonTest {
assertTrue(drawableBounds.right > 0);
assertTrue(drawableBounds.bottom > 0);
}
@Test
public void testBackgroundAfterHighlight() {
Drawable background = new ColorDrawable();
mMenuButton.setOriginalBackgroundForTesting(background);
Assert.assertNotNull("Background shouldn't be null.", mMenuButton.getBackground());
mMenuButton.setMenuButtonHighlight(true);
Assert.assertNotEquals(
"Background should have been updated.", background, mMenuButton.getBackground());
mMenuButton.setMenuButtonHighlight(false);
Assert.assertEquals("Background should be reset.", background, mMenuButton.getBackground());
}
}
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