Commit 1b311bb1 authored by Manu Cornet's avatar Manu Cornet Committed by Commit Bot

CrOS Shelf: Fix navigation widget position in RTL

Add a test to prevent future regressions.

BUG=991919

Change-Id: I41ebd4f5cee6375f0cb2d510b8d4e91d356a1bc0
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1761226Reviewed-by: default avatarXiyuan Xia <xiyuan@chromium.org>
Commit-Queue: Manu Cornet <manucornet@chromium.org>
Cr-Commit-Position: refs/heads/master@{#688293}
parent 5e608df4
...@@ -1142,8 +1142,10 @@ void ShelfLayoutManager::CalculateTargetBounds( ...@@ -1142,8 +1142,10 @@ void ShelfLayoutManager::CalculateTargetBounds(
gfx::Point nav_origin = gfx::Point nav_origin =
gfx::Point(ShelfConstants::home_button_edge_spacing(), gfx::Point(ShelfConstants::home_button_edge_spacing(),
ShelfConstants::home_button_edge_spacing()); ShelfConstants::home_button_edge_spacing());
target_bounds->nav_bounds_in_shelf = const gfx::Size nav_size = shelf_widget_->navigation_widget()->GetIdealSize();
gfx::Rect(nav_origin, shelf_widget_->navigation_widget()->GetIdealSize()); if (shelf_->IsHorizontalAlignment() && base::i18n::IsRTL())
nav_origin.set_x(shelf_width - nav_size.width() - nav_origin.x());
target_bounds->nav_bounds_in_shelf = gfx::Rect(nav_origin, nav_size);
gfx::Point hotseat_origin; gfx::Point hotseat_origin;
int hotseat_width; int hotseat_width;
......
...@@ -56,6 +56,7 @@ ...@@ -56,6 +56,7 @@
#include "ash/wm/workspace_controller.h" #include "ash/wm/workspace_controller.h"
#include "base/bind.h" #include "base/bind.h"
#include "base/command_line.h" #include "base/command_line.h"
#include "base/i18n/rtl.h"
#include "base/run_loop.h" #include "base/run_loop.h"
#include "base/stl_util.h" #include "base/stl_util.h"
#include "base/test/metrics/user_action_tester.h" #include "base/test/metrics/user_action_tester.h"
...@@ -3058,6 +3059,34 @@ TEST_F(ShelfLayoutManagerTest, AutoHideShelfHiddenForSinglePipWindow) { ...@@ -3058,6 +3059,34 @@ TEST_F(ShelfLayoutManagerTest, AutoHideShelfHiddenForSinglePipWindow) {
EXPECT_EQ(SHELF_AUTO_HIDE_HIDDEN, shelf->GetAutoHideState()); EXPECT_EQ(SHELF_AUTO_HIDE_HIDDEN, shelf->GetAutoHideState());
} }
// Verifies that shelf components are placed properly in right-to-left UI.
TEST_F(ShelfLayoutManagerTest, RtlPlacement) {
// Helper function to check that the given widget is placed symmetrically
// between LTR and RTL.
auto check_mirrored_placement = [](views::Widget* widget) {
base::i18n::SetICUDefaultLocale("en");
EXPECT_FALSE(base::i18n::IsRTL());
GetShelfLayoutManager()->LayoutShelf();
const int ltr_left_position =
widget->GetNativeWindow()->GetBoundsInScreen().x();
base::i18n::SetICUDefaultLocale("ar");
EXPECT_TRUE(base::i18n::IsRTL());
GetShelfLayoutManager()->LayoutShelf();
const int rtl_right_position =
widget->GetNativeWindow()->GetBoundsInScreen().right();
EXPECT_EQ(
GetShelfWidget()->GetWindowBoundsInScreen().width() - ltr_left_position,
rtl_right_position);
};
ShelfWidget* shelf_widget = GetPrimaryShelf()->shelf_widget();
check_mirrored_placement(shelf_widget->navigation_widget());
check_mirrored_placement(shelf_widget->status_area_widget());
check_mirrored_placement(shelf_widget);
}
class ShelfLayoutManagerKeyboardTest : public AshTestBase { class ShelfLayoutManagerKeyboardTest : public AshTestBase {
public: public:
ShelfLayoutManagerKeyboardTest() = default; ShelfLayoutManagerKeyboardTest() = default;
......
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