Commit 64e55bf6 authored by Jazz Xu's avatar Jazz Xu Committed by Commit Bot

CrOS GMC: Fix wrong artwork position in RTL.

Bug: 1138519
Change-Id: I985ff3044f154f8f07a84ce76435d63a9ce844a6
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2472477Reviewed-by: default avatarTommy Steimel <steimel@chromium.org>
Commit-Queue: Jazz Xu <jazzhsu@chromium.org>
Cr-Commit-Position: refs/heads/master@{#817711}
parent e81e0efa
...@@ -44,8 +44,12 @@ gfx::Rect MediaNotificationBackgroundAshImpl::GetArtworkBounds( ...@@ -44,8 +44,12 @@ gfx::Rect MediaNotificationBackgroundAshImpl::GetArtworkBounds(
int vertical_offset = (kArtworkSize.height() - target_size.height()) / 2; int vertical_offset = (kArtworkSize.height() - target_size.height()) / 2;
int horizontal_offset = (kArtworkSize.width() - target_size.width()) / 2; int horizontal_offset = (kArtworkSize.width() - target_size.width()) / 2;
return gfx::Rect(view_bounds.right() - kArtworkRightMargin - int bounds_x = base::i18n::IsRTL()
kArtworkSize.width() + horizontal_offset, ? view_bounds.x() + kArtworkRightMargin + horizontal_offset
: view_bounds.right() - kArtworkRightMargin -
kArtworkSize.width() + horizontal_offset;
return gfx::Rect(bounds_x,
view_bounds.bottom() - kArtworkBottomMargin - view_bounds.bottom() - kArtworkBottomMargin -
kArtworkSize.height() + vertical_offset, kArtworkSize.height() + vertical_offset,
target_size.width(), target_size.height()); target_size.width(), target_size.height());
......
...@@ -4,6 +4,7 @@ ...@@ -4,6 +4,7 @@
#include "components/media_message_center/media_notification_background_ash_impl.h" #include "components/media_message_center/media_notification_background_ash_impl.h"
#include "base/i18n/rtl.h"
#include "testing/gtest/include/gtest/gtest.h" #include "testing/gtest/include/gtest/gtest.h"
namespace media_message_center { namespace media_message_center {
...@@ -45,6 +46,10 @@ TEST_F(MediaNotificationBackgroundAshImplTest, ArtworkBoundsTest) { ...@@ -45,6 +46,10 @@ TEST_F(MediaNotificationBackgroundAshImplTest, ArtworkBoundsTest) {
background()->UpdateArtwork(CreateTestImage(40, 20)); background()->UpdateArtwork(CreateTestImage(40, 20));
EXPECT_EQ(GetArtworkBounds(parent_bounds).size(), gfx::Size(80, 40)); EXPECT_EQ(GetArtworkBounds(parent_bounds).size(), gfx::Size(80, 40));
base::i18n::SetRTLForTesting(true);
background()->UpdateArtwork(CreateTestImage(40, 80));
EXPECT_EQ(GetArtworkBounds(parent_bounds), gfx::Rect(36, 4, 40, 80));
} }
} // namespace media_message_center } // namespace media_message_center
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