Commit 4f5e14ee authored by Thomas Tellier's avatar Thomas Tellier Committed by Chromium LUCI CQ

[CrOS] Fix public account arrow button size on login screen

Bug: 1158825
Change-Id: I740a162a81768fa2cc7271315b553070636757fa
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2592800
Commit-Queue: Thomas Tellier <tellier@google.com>
Reviewed-by: default avatarRoman Sorokin [CET] <rsorokin@chromium.org>
Cr-Commit-Position: refs/heads/master@{#837550}
parent 7f591922
...@@ -93,7 +93,17 @@ LoginPublicAccountUserView::LoginPublicAccountUserView( ...@@ -93,7 +93,17 @@ LoginPublicAccountUserView::LoginPublicAccountUserView(
add_padding(kDistanceFromTopOfBigUserViewToUserIconDp); add_padding(kDistanceFromTopOfBigUserViewToUserIconDp);
AddChildView(std::move(wrapped_user_view)); AddChildView(std::move(wrapped_user_view));
add_padding(kDistanceFromUserViewToArrowButton); add_padding(kDistanceFromUserViewToArrowButton);
arrow_button_ = AddChildView(std::move(arrow_button));
// Arrow button size should be its preferred size so we wrap it.
auto* arrow_button_container =
AddChildView(std::make_unique<NonAccessibleView>());
auto container_layout = std::make_unique<views::BoxLayout>(
views::BoxLayout::Orientation::kHorizontal);
container_layout->set_main_axis_alignment(
views::BoxLayout::MainAxisAlignment::kCenter);
arrow_button_container->SetLayoutManager(std::move(container_layout));
arrow_button_ = arrow_button_container->AddChildView(std::move(arrow_button));
add_padding(kDistanceFromArrowButtonToBigUserViewBottom); add_padding(kDistanceFromArrowButtonToBigUserViewBottom);
// Update authentication UI. // Update authentication UI.
......
...@@ -174,29 +174,36 @@ TEST_F(LoginPublicAccountUserViewTest, ArrowButtonDoesNotChangeViewBounds) { ...@@ -174,29 +174,36 @@ TEST_F(LoginPublicAccountUserViewTest, ArrowButtonDoesNotChangeViewBounds) {
public_account_view_->GetBoundsInScreen(); public_account_view_->GetBoundsInScreen();
EXPECT_NE(auth_disabled_bounds, gfx::Rect()); EXPECT_NE(auth_disabled_bounds, gfx::Rect());
auto* arrow_button = public_account_test.arrow_button();
// Move mouse over the view, the arrow button becomes opaque. // Move mouse over the view, the arrow button becomes opaque.
// View bounds should not change. // View bounds should not change.
GetEventGenerator()->MoveMouseTo( GetEventGenerator()->MoveMouseTo(
public_account_view_->user_view()->GetBoundsInScreen().CenterPoint()); public_account_view_->user_view()->GetBoundsInScreen().CenterPoint());
EXPECT_EQ(public_account_test.arrow_button()->layer()->opacity(), 1); EXPECT_EQ(arrow_button->layer()->opacity(), 1);
EXPECT_EQ(public_account_view_->GetBoundsInScreen(), auth_disabled_bounds); EXPECT_EQ(public_account_view_->GetBoundsInScreen(), auth_disabled_bounds);
EXPECT_EQ(public_account_view_->GetBoundsInScreen().x(), int arrow_left_margin = arrow_button->GetBoundsInScreen().x();
public_account_test.arrow_button()->GetBoundsInScreen().x()); int arrow_right_margin = public_account_view_->GetBoundsInScreen().width() -
arrow_button->GetBoundsInScreen().x() -
arrow_button->GetBoundsInScreen().width();
EXPECT_NEAR(arrow_left_margin, arrow_right_margin, 1);
// Move out the view makes it non-opaque. View bounds should stay the same. // Move out the view makes it non-opaque. View bounds should stay the same.
GetEventGenerator()->MoveMouseTo( GetEventGenerator()->MoveMouseTo(
focusable_view_->GetBoundsInScreen().CenterPoint()); focusable_view_->GetBoundsInScreen().CenterPoint());
EXPECT_EQ(public_account_test.arrow_button()->layer()->opacity(), 0); EXPECT_EQ(arrow_button->layer()->opacity(), 0);
EXPECT_EQ(public_account_view_->GetBoundsInScreen(), auth_disabled_bounds); EXPECT_EQ(public_account_view_->GetBoundsInScreen(), auth_disabled_bounds);
// Set auth enable forces arrow button to be opaque. // Set auth enable forces arrow button to be opaque.
// View bounds should not change. // View bounds should not change.
public_account_view_->SetAuthEnabled(true /*enabled*/, false /*animate*/); public_account_view_->SetAuthEnabled(true /*enabled*/, false /*animate*/);
EXPECT_TRUE(public_account_view_->auth_enabled()); EXPECT_TRUE(public_account_view_->auth_enabled());
EXPECT_EQ(public_account_test.arrow_button()->layer()->opacity(), 1); EXPECT_EQ(arrow_button->layer()->opacity(), 1);
EXPECT_EQ(public_account_view_->GetBoundsInScreen(), auth_disabled_bounds); EXPECT_EQ(public_account_view_->GetBoundsInScreen(), auth_disabled_bounds);
EXPECT_EQ(public_account_view_->GetBoundsInScreen().x(), arrow_left_margin = arrow_button->GetBoundsInScreen().x();
public_account_test.arrow_button()->GetBoundsInScreen().x()); arrow_right_margin = public_account_view_->GetBoundsInScreen().width() -
arrow_button->GetBoundsInScreen().x() -
arrow_button->GetBoundsInScreen().width();
EXPECT_NEAR(arrow_left_margin, arrow_right_margin, 1);
} }
} // namespace ash } // namespace ash
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