Commit be452be4 authored by Thomas Tellier's avatar Thomas Tellier Committed by Commit Bot

[CrOs] Make login bubbles use default positioning strategies

Bug: 1109266
Change-Id: Ia930e9aa352fe24eb5b10ecad2b47d4a7d2b21c9
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2414394
Commit-Queue: Thomas Tellier <tellier@google.com>
Reviewed-by: default avatarRoman Aleksandrov <raleksandrov@google.com>
Reviewed-by: default avatarDenis Kuznetsov [CET] <antrim@chromium.org>
Cr-Commit-Position: refs/heads/master@{#821563}
parent 7ac640da
......@@ -619,8 +619,8 @@ component("ash") {
"login/ui/login_pin_view.h",
"login/ui/login_public_account_user_view.cc",
"login/ui/login_public_account_user_view.h",
"login/ui/login_unpositioned_tooltip_view.cc",
"login/ui/login_unpositioned_tooltip_view.h",
"login/ui/login_tooltip_view.cc",
"login/ui/login_tooltip_view.h",
"login/ui/login_user_menu_view.cc",
"login/ui/login_user_menu_view.h",
"login/ui/login_user_view.cc",
......
......@@ -228,12 +228,12 @@ bool LoginScreenTestApi::IsEnterpriseEnrollmentButtonShown() {
}
// static
bool LoginScreenTestApi::IsUserAddingScreenBubbleShown() {
bool LoginScreenTestApi::IsUserAddingScreenIndicatorShown() {
LockScreen::TestApi lock_screen_test(LockScreen::Get());
LockContentsView::TestApi lock_contents_test(
lock_screen_test.contents_view());
views::View* bubble = lock_contents_test.user_adding_screen_bubble();
return bubble && bubble->GetVisible();
views::View* indicator = lock_contents_test.user_adding_screen_indicator();
return indicator && indicator->GetVisible();
}
// static
......
This diff is collapsed.
......@@ -17,7 +17,7 @@
#include "ash/login/ui/login_data_dispatcher.h"
#include "ash/login/ui/login_display_style.h"
#include "ash/login/ui/login_error_bubble.h"
#include "ash/login/ui/login_unpositioned_tooltip_view.h"
#include "ash/login/ui/login_tooltip_view.h"
#include "ash/login/ui/non_accessible_view.h"
#include "ash/public/cpp/keyboard/keyboard_controller_observer.h"
#include "ash/public/cpp/login_accelerators.h"
......@@ -72,9 +72,7 @@ class ASH_EXPORT LockContentsView
public:
METADATA_HEADER(LockContentsView);
class AuthErrorBubble;
class ManagementPopUp;
class LoginTooltipView;
class UserAddingPopUp;
class ManagementBubble;
class UserState;
enum class BottomIndicatorState {
......@@ -101,7 +99,7 @@ class ASH_EXPORT LockContentsView
LoginErrorBubble* detachable_base_error_bubble() const;
LoginErrorBubble* warning_banner_bubble() const;
LoginErrorBubble* supervised_user_deprecation_bubble() const;
views::View* user_adding_screen_bubble() const;
views::View* user_adding_screen_indicator() const;
views::View* system_info() const;
views::View* bottom_status_indicator() const;
BottomIndicatorState bottom_status_indicator_status() const;
......@@ -303,6 +301,10 @@ class ASH_EXPORT LockContentsView
// device is enrolled.
void LayoutBottomStatusIndicator();
// Lay out the user adding screen indicator. This is called when a secondary
// user is being added.
void LayoutUserAddingScreenIndicator();
// Lay out the expanded public session view.
void LayoutPublicSessionView();
......@@ -459,10 +461,10 @@ class ASH_EXPORT LockContentsView
// Bubble for displaying easy-unlock tooltips.
LoginTooltipView* tooltip_bubble_;
// Bubble for displaying management details.
ManagementPopUp* management_bubble_;
// Bubble for displaying a warning message when a secondary user is being
// added.
UserAddingPopUp* user_adding_screen_bubble_ = nullptr;
ManagementBubble* management_bubble_;
// Indicator at top of screen for displaying a warning message when a
// secondary user is being added.
views::View* user_adding_screen_indicator_ = nullptr;
// Bubble for displaying warning banner message.
LoginErrorBubble* warning_banner_bubble_;
// Bubble for displaying supervised user deprecation message.
......
......@@ -35,7 +35,7 @@ constexpr int kBubblePaddingDp = 16;
constexpr int kBubbleBetweenChildSpacingDp = 16;
// Border radius of the rounded bubble.
constexpr int kErrorBubbleBorderRadius = 8;
constexpr int kBubbleBorderRadius = 8;
// The amount of time for bubble show/hide animation.
constexpr base::TimeDelta kBubbleAnimationDuration =
......@@ -81,7 +81,7 @@ class LoginBubbleHandler : public ui::EventHandler {
if (login_views_utils::HasFocusInAnyChildView(bubble_))
return;
if (!bubble_->IsPersistent())
if (!bubble_->is_persistent())
bubble_->Hide();
}
......@@ -105,7 +105,7 @@ class LoginBubbleHandler : public ui::EventHandler {
return;
}
if (!bubble_->IsPersistent())
if (!bubble_->is_persistent())
bubble_->Hide();
}
......@@ -141,7 +141,7 @@ void LoginBaseBubbleView::EnsureLayer() {
layer()->SetBackgroundBlur(
static_cast<float>(AshColorProvider::LayerBlurSigma::kBlurDefault));
SetBackground(views::CreateRoundedRectBackground(background_color,
kErrorBubbleBorderRadius));
kBubbleBorderRadius));
layer()->SetFillsBoundsOpaquely(false);
}
......@@ -169,21 +169,55 @@ LoginButton* LoginBaseBubbleView::GetBubbleOpener() const {
return nullptr;
}
bool LoginBaseBubbleView::IsPersistent() const {
return false;
}
void LoginBaseBubbleView::SetPersistent(bool persistent) {}
gfx::Point LoginBaseBubbleView::CalculatePosition() {
if (GetAnchorView()) {
gfx::Point bottom_left = GetAnchorView()->bounds().bottom_left();
if (!GetAnchorView())
return gfx::Point();
// Views' positions are defined in the parents' coordinate system. Therefore,
// the position of the bubble needs to be returned in its parent's coordinate
// system. kTryBeforeThenAfter and kTryAfterThenBefore use strategies implying
// to know the bounds of the entire window; therefore, resulting position is
// calculated by using the root view's coordinates system. kShowAbove and
// kShowBelow are less complicated, they only use the coordinate system of the
// the anchor view's parent.
gfx::Point anchor_position = GetAnchorView()->bounds().origin();
ConvertPointToTarget(GetAnchorView()->parent() /*source*/,
parent() /*target*/, &bottom_left);
return bottom_left;
GetAnchorView()->GetWidget()->GetRootView() /*target*/,
&anchor_position);
auto bounds = GetBoundsAvailableToShowBubble();
gfx::Size bubble_size(width() + 2 * horizontal_padding_,
height() + vertical_padding_);
gfx::Point result;
View* source;
switch (positioning_strategy_) {
case PositioningStrategy::kTryBeforeThenAfter:
result = login_views_utils::CalculateBubblePositionBeforeAfterStrategy(
{anchor_position, GetAnchorView()->size()}, bubble_size, bounds);
source = GetAnchorView()->GetWidget()->GetRootView();
break;
case PositioningStrategy::kTryAfterThenBefore:
result = login_views_utils::CalculateBubblePositionAfterBeforeStrategy(
{anchor_position, GetAnchorView()->size()}, bubble_size, bounds);
source = GetAnchorView()->GetWidget()->GetRootView();
break;
case PositioningStrategy::kShowAbove: {
gfx::Point top_center = GetAnchorView()->bounds().top_center();
result = top_center - gfx::Vector2d(GetPreferredSize().width() / 2,
GetPreferredSize().height());
source = GetAnchorView()->parent();
break;
}
return gfx::Point();
case PositioningStrategy::kShowBelow: {
result = GetAnchorView()->bounds().bottom_left();
source = GetAnchorView()->parent();
break;
}
}
// Get position of the bubble surrounded by paddings.
result.Offset(horizontal_padding_, 0);
ConvertPointToTarget(source /*source*/, parent() /*target*/, &result);
return result;
}
void LoginBaseBubbleView::SetAnchorView(views::View* anchor_view) {
......@@ -226,36 +260,10 @@ void LoginBaseBubbleView::OnBlur() {
Hide();
}
gfx::Point LoginBaseBubbleView::CalculatePositionUsingDefaultStrategy(
PositioningStrategy strategy,
int horizontal_padding,
int vertical_padding) const {
if (!GetAnchorView())
return gfx::Point();
gfx::Point anchor_position = GetAnchorView()->bounds().origin();
ConvertPointToTarget(GetAnchorView()->parent() /*source*/,
GetAnchorView()->GetWidget()->GetRootView() /*target*/,
&anchor_position);
auto bounds = GetBoundsAvailableToShowBubble();
gfx::Size bubble_size(width() + 2 * horizontal_padding,
height() + vertical_padding);
gfx::Point result = gfx::Point();
switch (strategy) {
case PositioningStrategy::kShowOnLeftSideOrRightSide:
result = login_views_utils::CalculateBubblePositionLeftRightStrategy(
{anchor_position, GetAnchorView()->size()}, bubble_size, bounds);
break;
case PositioningStrategy::kShowOnRightSideOrLeftSide:
result = login_views_utils::CalculateBubblePositionRightLeftStrategy(
{anchor_position, GetAnchorView()->size()}, bubble_size, bounds);
break;
}
// Get position of the bubble surrounded by paddings.
result.Offset(horizontal_padding, 0);
ConvertPointToTarget(GetAnchorView()->GetWidget()->GetRootView() /*source*/,
parent() /*target*/, &result);
return result;
void LoginBaseBubbleView::SetPadding(int horizontal_padding,
int vertical_padding) {
horizontal_padding_ = horizontal_padding;
vertical_padding_ = vertical_padding;
}
gfx::Rect LoginBaseBubbleView::GetBoundsAvailableToShowBubble() const {
......
......@@ -20,12 +20,27 @@ class LoginBubbleHandler;
class ASH_EXPORT LoginBaseBubbleView : public views::View,
public ui::LayerAnimationObserver {
public:
enum class PositioningStrategy {
// Try to show the bubble after the anchor (on the right side in LTR), if
// there is no space show before.
kTryAfterThenBefore,
// Try to show the bubble before the anchor (on the left side in LTR), if
// there is no space show after.
kTryBeforeThenAfter,
// Show the bubble above the anchor.
kShowAbove,
// Show the bubble on the bottom left of the anchor.
kShowBelow,
};
// Without specifying a parent_window, the bubble will default to being in the
// same container as anchor_view.
explicit LoginBaseBubbleView(views::View* anchor_view);
explicit LoginBaseBubbleView(views::View* anchor_view,
gfx::NativeView parent_window);
~LoginBaseBubbleView() override;
LoginBaseBubbleView(const LoginBaseBubbleView&) = delete;
LoginBaseBubbleView& operator=(const LoginBaseBubbleView&) = delete;
void Show();
void Hide();
......@@ -34,12 +49,9 @@ class ASH_EXPORT LoginBaseBubbleView : public views::View,
virtual LoginButton* GetBubbleOpener() const;
// Returns whether or not this bubble should show persistently.
virtual bool IsPersistent() const;
bool is_persistent() const { return is_persistent_; }
// Change the persistence of the bubble.
virtual void SetPersistent(bool persistent);
// Determine the position of the bubble prior to showing.
virtual gfx::Point CalculatePosition();
void set_persistent(bool is_persistent) { is_persistent_ = is_persistent; }
void SetAnchorView(views::View* anchor_view);
views::View* GetAnchorView() const { return anchor_view_; }
......@@ -55,20 +67,12 @@ class ASH_EXPORT LoginBaseBubbleView : public views::View,
void Layout() override;
void OnBlur() override;
protected:
enum class PositioningStrategy {
// Try to show bubble on the right side of the anchor, if there is no space
// show on the left side.
kShowOnRightSideOrLeftSide,
// Try to show bubble on the left side of the anchor, if there is no space
// show on the right side.
kShowOnLeftSideOrRightSide,
};
// Returns calculated position using default positioning strategies.
gfx::Point CalculatePositionUsingDefaultStrategy(PositioningStrategy strategy,
int horizontal_padding,
int vertical_padding) const;
void set_positioning_strategy(PositioningStrategy positioning_strategy) {
positioning_strategy_ = positioning_strategy;
}
void SetPadding(int horizontal_padding, int vertical_padding);
protected:
// Return area where bubble could be shown in.
gfx::Rect GetBoundsAvailableToShowBubble() const;
......@@ -83,11 +87,19 @@ class ASH_EXPORT LoginBaseBubbleView : public views::View,
gfx::Rect GetWorkArea() const;
void ScheduleAnimation(bool visible);
// Determine the position of the bubble prior to showing.
gfx::Point CalculatePosition();
views::View* anchor_view_;
std::unique_ptr<LoginBubbleHandler> bubble_handler_;
DISALLOW_COPY_AND_ASSIGN(LoginBaseBubbleView);
bool is_persistent_ = false;
// Positioning strategy of the bubble.
PositioningStrategy positioning_strategy_ = PositioningStrategy::kShowBelow;
int horizontal_padding_ = 0;
int vertical_padding_ = 0;
};
} // namespace ash
......
......@@ -26,14 +26,11 @@ constexpr int kAlertIconSizeDp = 20;
} // namespace
LoginErrorBubble::LoginErrorBubble()
: LoginErrorBubble(nullptr /*content*/,
nullptr /*anchor_view*/,
false /*is_persistent*/) {}
: LoginErrorBubble(nullptr /*content*/, nullptr /*anchor_view*/) {}
LoginErrorBubble::LoginErrorBubble(views::View* content,
views::View* anchor_view,
bool is_persistent)
: LoginBaseBubbleView(anchor_view), is_persistent_(is_persistent) {
views::View* anchor_view)
: LoginBaseBubbleView(anchor_view) {
views::ImageView* alert_icon = new views::ImageView();
alert_icon->SetPreferredSize(gfx::Size(kAlertIconSizeDp, kAlertIconSizeDp));
alert_icon->SetImage(
......@@ -64,14 +61,6 @@ void LoginErrorBubble::SetAccessibleName(const base::string16& name) {
accessible_name_ = name;
}
bool LoginErrorBubble::IsPersistent() const {
return is_persistent_;
}
void LoginErrorBubble::SetPersistent(bool persistent) {
is_persistent_ = persistent;
}
const char* LoginErrorBubble::GetClassName() const {
return "LoginErrorBubble";
}
......
......@@ -15,9 +15,7 @@ namespace ash {
class ASH_EXPORT LoginErrorBubble : public LoginBaseBubbleView {
public:
LoginErrorBubble();
LoginErrorBubble(views::View* content,
views::View* anchor_view,
bool is_persistent);
LoginErrorBubble(views::View* content, views::View* anchor_view);
~LoginErrorBubble() override;
void SetContent(views::View* content);
......@@ -29,17 +27,12 @@ class ASH_EXPORT LoginErrorBubble : public LoginBaseBubbleView {
// on bubble show – when the alert event occurs.
void SetAccessibleName(const base::string16& name);
// LoginBaseBubbleView:
bool IsPersistent() const override;
void SetPersistent(bool persistent) override;
// views::View:
const char* GetClassName() const override;
void GetAccessibleNodeData(ui::AXNodeData* node_data) override;
private:
views::View* content_ = nullptr;
bool is_persistent_;
// Accessibility data.
base::string16 accessible_name_;
......
......@@ -26,8 +26,8 @@ TEST_F(LoginErrorBubbleTest, PersistentEventHandling) {
views::style::CONTEXT_LABEL,
views::style::STYLE_PRIMARY);
auto* bubble = new LoginErrorBubble(label /*content*/, anchor_view,
true /*is_persistent*/);
auto* bubble = new LoginErrorBubble(label /*content*/, anchor_view);
bubble->set_persistent(true);
container->AddChildView(bubble);
EXPECT_FALSE(bubble->GetVisible());
......
......@@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "ash/login/ui/login_unpositioned_tooltip_view.h"
#include "ash/login/ui/login_tooltip_view.h"
#include "ash/login/ui/non_accessible_view.h"
#include "ash/login/ui/views_utils.h"
......@@ -24,8 +24,7 @@ constexpr int kInfoIconSizeDp = 20;
} // namespace
LoginUnpositionedTooltipView::LoginUnpositionedTooltipView(
const base::string16& message,
LoginTooltipView::LoginTooltipView(const base::string16& message,
views::View* anchor_view)
: LoginBaseBubbleView(anchor_view) {
views::ImageView* info_icon = new views::ImageView();
......@@ -38,14 +37,13 @@ LoginUnpositionedTooltipView::LoginUnpositionedTooltipView(
AddChildView(label_);
}
LoginUnpositionedTooltipView::~LoginUnpositionedTooltipView() = default;
LoginTooltipView::~LoginTooltipView() = default;
void LoginUnpositionedTooltipView::SetText(const base::string16& message) {
void LoginTooltipView::SetText(const base::string16& message) {
label_->SetText(message);
}
void LoginUnpositionedTooltipView::GetAccessibleNodeData(
ui::AXNodeData* node_data) {
void LoginTooltipView::GetAccessibleNodeData(ui::AXNodeData* node_data) {
node_data->role = ax::mojom::Role::kTooltip;
}
......
......@@ -2,8 +2,8 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef ASH_LOGIN_UI_LOGIN_UNPOSITIONED_TOOLTIP_VIEW_H_
#define ASH_LOGIN_UI_LOGIN_UNPOSITIONED_TOOLTIP_VIEW_H_
#ifndef ASH_LOGIN_UI_LOGIN_TOOLTIP_VIEW_H_
#define ASH_LOGIN_UI_LOGIN_TOOLTIP_VIEW_H_
#include "ash/login/ui/login_base_bubble_view.h"
#include "ui/accessibility/ax_node_data.h"
......@@ -15,13 +15,10 @@ class Label;
namespace ash {
// TODO(crbug.com/1109266): Get rid of this class and make
// LoginBaseBubbleView more configurable.
class LoginUnpositionedTooltipView : public LoginBaseBubbleView {
class LoginTooltipView : public LoginBaseBubbleView {
public:
LoginUnpositionedTooltipView(const base::string16& message,
views::View* anchor_view);
~LoginUnpositionedTooltipView() override;
LoginTooltipView(const base::string16& message, views::View* anchor_view);
~LoginTooltipView() override;
void SetText(const base::string16& message);
......@@ -34,9 +31,9 @@ class LoginUnpositionedTooltipView : public LoginBaseBubbleView {
private:
views::Label* label_ = nullptr;
DISALLOW_COPY_AND_ASSIGN(LoginUnpositionedTooltipView);
DISALLOW_COPY_AND_ASSIGN(LoginTooltipView);
};
} // namespace ash
#endif // ASH_LOGIN_UI_LOGIN_UNPOSITIONED_TOOLTIP_VIEW_H_
#endif // ASH_LOGIN_UI_LOGIN_TOOLTIP_VIEW_H_
......@@ -191,6 +191,10 @@ LoginUserMenuView::LoginUserMenuView(
remove_user_button_->SetID(kUserMenuRemoveUserButtonIdForTest);
AddChildView(remove_user_button_);
}
set_positioning_strategy(PositioningStrategy::kTryAfterThenBefore);
SetPadding(kHorizontalPaddingLoginUserMenuViewDp,
kVerticalPaddingLoginUserMenuViewDp);
}
LoginUserMenuView::~LoginUserMenuView() = default;
......@@ -243,13 +247,6 @@ void LoginUserMenuView::ButtonPressed(views::Button* sender,
std::move(on_remove_user_requested_).Run();
}
gfx::Point LoginUserMenuView::CalculatePosition() {
return CalculatePositionUsingDefaultStrategy(
PositioningStrategy::kShowOnRightSideOrLeftSide,
kHorizontalPaddingLoginUserMenuViewDp,
kVerticalPaddingLoginUserMenuViewDp);
}
void LoginUserMenuView::RequestFocus() {
// This view has no actual interesting contents to focus, so immediately
// forward to the button.
......
......@@ -49,7 +49,6 @@ class ASH_EXPORT LoginUserMenuView : public LoginBaseBubbleView,
// LoginBaseBubbleView:
LoginButton* GetBubbleOpener() const override;
gfx::Point CalculatePosition() override;
// views::ButtonListener:
void ButtonPressed(views::Button* sender, const ui::Event& event) override;
......
......@@ -148,13 +148,13 @@ views::View* GetBubbleContainer(views::View* view) {
return container;
}
gfx::Point CalculateBubblePositionLeftRightStrategy(gfx::Rect anchor,
gfx::Point CalculateBubblePositionBeforeAfterStrategy(gfx::Rect anchor,
gfx::Size bubble,
gfx::Rect bounds) {
gfx::Rect result(anchor.x() - bubble.width(), anchor.y(), bubble.width(),
bubble.height());
// Trying to show on the left side.
// If there is not enough space show on the right side.
// Trying to show before (on the left side in LTR).
// If there is not enough space show after (on the right side in LTR).
if (result.x() < bounds.x()) {
result.Offset(anchor.width() + result.width(), 0);
}
......@@ -162,13 +162,13 @@ gfx::Point CalculateBubblePositionLeftRightStrategy(gfx::Rect anchor,
return result.origin();
}
gfx::Point CalculateBubblePositionRightLeftStrategy(gfx::Rect anchor,
gfx::Point CalculateBubblePositionAfterBeforeStrategy(gfx::Rect anchor,
gfx::Size bubble,
gfx::Rect bounds) {
gfx::Rect result(anchor.x() + anchor.width(), anchor.y(), bubble.width(),
bubble.height());
// Trying to show on the right side.
// If there is not enough space show on the left side.
// Trying to show after (on the right side in LTR).
// If there is not enough space show before (on the left side in LTR).
if (result.right() > bounds.right()) {
result.Offset(-anchor.width() - result.width(), 0);
}
......
......@@ -44,12 +44,12 @@ views::Label* CreateBubbleLabel(
// Get the bubble container for |view| to place a LoginBaseBubbleView.
views::View* GetBubbleContainer(views::View* view);
ASH_EXPORT gfx::Point CalculateBubblePositionLeftRightStrategy(
ASH_EXPORT gfx::Point CalculateBubblePositionAfterBeforeStrategy(
gfx::Rect anchor,
gfx::Size bubble,
gfx::Rect bounds);
ASH_EXPORT gfx::Point CalculateBubblePositionRightLeftStrategy(
ASH_EXPORT gfx::Point CalculateBubblePositionBeforeAfterStrategy(
gfx::Rect anchor,
gfx::Size bubble,
gfx::Rect bounds);
......
......@@ -23,78 +23,78 @@ class ViewsUtilsUnittest : public testing::Test {
} // namespace
TEST_F(ViewsUtilsUnittest, LeftRightStrategySimpleTest) {
TEST_F(ViewsUtilsUnittest, BeforeAfterStrategySimpleTest) {
const gfx::Rect anchor(10, 10, 10, 10);
const gfx::Size bubble(5, 5);
const gfx::Rect bounds(20, 20);
const gfx::Point result_point(anchor.x() - bubble.width(), anchor.y());
EXPECT_EQ(result_point,
CalculateBubblePositionLeftRightStrategy(anchor, bubble, bounds));
CalculateBubblePositionBeforeAfterStrategy(anchor, bubble, bounds));
}
TEST_F(ViewsUtilsUnittest, LeftRightStrategyNotEnoughHeightBottom) {
TEST_F(ViewsUtilsUnittest, BeforeAfterStrategyNotEnoughHeightBottom) {
const gfx::Rect anchor(10, 10, 10, 10);
const gfx::Size bubble(5, 15);
const gfx::Rect bounds(20, 20);
const gfx::Point result_point(anchor.x() - bubble.width(),
bounds.height() - bubble.height());
EXPECT_EQ(result_point,
CalculateBubblePositionLeftRightStrategy(anchor, bubble, bounds));
CalculateBubblePositionBeforeAfterStrategy(anchor, bubble, bounds));
}
TEST_F(ViewsUtilsUnittest, LeftRightStrategyNotEnoughHeightBottomAndTop) {
TEST_F(ViewsUtilsUnittest, BeforeAfterStrategyNotEnoughHeightBottomAndTop) {
const gfx::Rect anchor(10, 10, 10, 10);
const gfx::Size bubble(5, 25);
const gfx::Rect bounds(20, 20);
const gfx::Point result_point(anchor.x() - bubble.width(), bounds.y());
EXPECT_EQ(result_point,
CalculateBubblePositionLeftRightStrategy(anchor, bubble, bounds));
CalculateBubblePositionBeforeAfterStrategy(anchor, bubble, bounds));
}
TEST_F(ViewsUtilsUnittest, LeftRightStrategyNotEnoughWidthLeft) {
TEST_F(ViewsUtilsUnittest, BeforeAfterStrategyNotEnoughWidthBefore) {
const gfx::Rect anchor(2, 10, 10, 10);
const gfx::Size bubble(5, 5);
const gfx::Rect bounds(20, 20);
const gfx::Point result_point(anchor.x() + anchor.width(), anchor.y());
EXPECT_EQ(result_point,
CalculateBubblePositionLeftRightStrategy(anchor, bubble, bounds));
CalculateBubblePositionBeforeAfterStrategy(anchor, bubble, bounds));
}
TEST_F(ViewsUtilsUnittest, RightLeftStrategySimpleTest) {
TEST_F(ViewsUtilsUnittest, AfterBeforeStrategySimpleTest) {
const gfx::Rect anchor(0, 10, 10, 10);
const gfx::Size bubble(5, 5);
const gfx::Rect bounds(20, 20);
const gfx::Point result_point(anchor.x() + anchor.width(), anchor.y());
EXPECT_EQ(result_point,
CalculateBubblePositionRightLeftStrategy(anchor, bubble, bounds));
CalculateBubblePositionAfterBeforeStrategy(anchor, bubble, bounds));
}
TEST_F(ViewsUtilsUnittest, RightLeftStrategyNotEnoughHeightBottom) {
TEST_F(ViewsUtilsUnittest, AfterBeforeStrategyNotEnoughHeightBottom) {
const gfx::Rect anchor(0, 10, 10, 10);
const gfx::Size bubble(5, 15);
const gfx::Rect bounds(20, 20);
const gfx::Point result_point(anchor.x() + anchor.width(),
bounds.height() - bubble.height());
EXPECT_EQ(result_point,
CalculateBubblePositionRightLeftStrategy(anchor, bubble, bounds));
CalculateBubblePositionAfterBeforeStrategy(anchor, bubble, bounds));
}
TEST_F(ViewsUtilsUnittest, RightLeftStrategyNotEnoughHeightBottomAndTop) {
TEST_F(ViewsUtilsUnittest, AfterBeforeStrategyNotEnoughHeightBottomAndTop) {
const gfx::Rect anchor(0, 10, 10, 10);
const gfx::Size bubble(5, 25);
const gfx::Rect bounds(20, 20);
const gfx::Point result_point(anchor.x() + anchor.width(), bounds.y());
EXPECT_EQ(result_point,
CalculateBubblePositionRightLeftStrategy(anchor, bubble, bounds));
CalculateBubblePositionAfterBeforeStrategy(anchor, bubble, bounds));
}
TEST_F(ViewsUtilsUnittest, RightLeftStrategyNotEnoughWidthRight) {
TEST_F(ViewsUtilsUnittest, AfterBeforeStrategyNotEnoughWidthAfter) {
const gfx::Rect anchor(10, 10, 10, 10);
const gfx::Size bubble(5, 5);
const gfx::Rect bounds(20, 20);
const gfx::Point result_point(anchor.x() - bubble.width(), anchor.y());
EXPECT_EQ(result_point,
CalculateBubblePositionRightLeftStrategy(anchor, bubble, bounds));
CalculateBubblePositionAfterBeforeStrategy(anchor, bubble, bounds));
}
} // namespace login_views_utils
......
......@@ -36,7 +36,7 @@ class ASH_PUBLIC_EXPORT LoginScreenTestApi {
static bool IsParentAccessButtonShown();
static bool IsEnterpriseEnrollmentButtonShown();
static bool IsWarningBubbleShown();
static bool IsUserAddingScreenBubbleShown();
static bool IsUserAddingScreenIndicatorShown();
static bool IsSystemInfoShown();
static bool IsPasswordFieldShown(const AccountId& account_id);
static bool IsDisplayPasswordButtonShown(const AccountId& account_id);
......
......@@ -583,7 +583,7 @@ IN_PROC_BROWSER_TEST_F(UserAddingScreenViewBasedTest, InfoBubbleVisible) {
EXPECT_EQ(session_manager::SessionManager::Get()->session_state(),
session_manager::SessionState::LOGIN_PRIMARY);
EXPECT_FALSE(ash::LoginScreenTestApi::IsUserAddingScreenBubbleShown());
EXPECT_FALSE(ash::LoginScreenTestApi::IsUserAddingScreenIndicatorShown());
LoginUser(users[0].account_id);
EXPECT_EQ(user_manager::UserManager::Get()->GetLoggedInUsers().size(), 1u);
......@@ -601,7 +601,7 @@ IN_PROC_BROWSER_TEST_F(UserAddingScreenViewBasedTest, InfoBubbleVisible) {
EXPECT_EQ(session_manager::SessionManager::Get()->session_state(),
session_manager::SessionState::LOGIN_SECONDARY);
EXPECT_TRUE(ash::LoginScreenTestApi::IsUserAddingScreenBubbleShown());
EXPECT_TRUE(ash::LoginScreenTestApi::IsUserAddingScreenIndicatorShown());
AddUser(users[i].account_id);
users_in_session_order_.push_back(users[i].account_id);
......
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