Commit d608deb8 authored by wutao's avatar wutao Committed by Chromium LUCI CQ

ambient: Fix media string not animate

It was not handled that when a media session info is changed from paused
to playing, the string animation will not restart.
This patch simplifies the logic, when the media is paused, it will only
set the visibility to false, but not stop the animation, when the media
resumes, it is still animating.

Bug: b/173804133
Test: manual and modified test
Change-Id: Ic2a935b2bc52d8379189395dd3fd1213eefd48a8
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2573682Reviewed-by: default avatarXiaohui Chen <xiaohuic@chromium.org>
Commit-Queue: Tao Wu <wutao@chromium.org>
Cr-Commit-Position: refs/heads/master@{#834001}
parent 5726486d
......@@ -128,10 +128,6 @@ const char* MediaStringView::GetClassName() const {
return "MediaStringView";
}
void MediaStringView::VisibilityChanged(View* starting_from, bool is_visible) {
media_text_->layer()->GetAnimator()->StopAnimating();
}
void MediaStringView::OnViewBoundsChanged(views::View* observed_view) {
UpdateMaskLayer();
}
......
......@@ -41,7 +41,6 @@ class MediaStringView : public views::View,
// views::View:
const char* GetClassName() const override;
void VisibilityChanged(View* starting_from, bool is_visible) override;
// views::ViewObserver:
void OnViewBoundsChanged(views::View* observed_view) override;
......
......@@ -226,7 +226,7 @@ TEST_F(MediaStringViewTest, ShouldStartAndStopAnimationWhenTextChanges) {
GetMediaStringViewTextLabel()->layer()->GetAnimator()->is_animating());
}
TEST_F(MediaStringViewTest, PauseMediaWillStopAnimationWithLongText) {
TEST_F(MediaStringViewTest, PauseMediaWillNotStopAnimationWithLongText) {
ui::ScopedAnimationDurationScaleMode test_duration_mode(
ui::ScopedAnimationDurationScaleMode::NORMAL_DURATION);
......@@ -253,7 +253,7 @@ TEST_F(MediaStringViewTest, PauseMediaWillStopAnimationWithLongText) {
SimulateMediaPlaybackStateChanged(
media_session::mojom::MediaPlaybackState::kPaused);
EXPECT_FALSE(GetMediaStringView()->GetVisible());
EXPECT_FALSE(
EXPECT_TRUE(
GetMediaStringViewTextLabel()->layer()->GetAnimator()->is_animating());
}
......
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