Commit c8df89ca authored by Ryan Hansberry's avatar Ryan Hansberry Committed by Commit Bot

Revert "Use arrow keys to navigate through users on Views-based login screen."

This reverts commit 0f9ea81e.

Reason for revert: this change has broken the Easy Unlock
feature. When Easy Unlock is enabled, its icon is intended
to appear in the password field of a user pod on the login
or lock screen. This change has prevented that icon from
displaying. More details at crbug.com/861918.

Original change's description:
> Use arrow keys to navigate through users on Views-based login screen.
>
> Bug: 845037
> Change-Id: I60574af1513793a0872c4d02c20c829f0adda9df
> Reviewed-on: https://chromium-review.googlesource.com/1117769
> Commit-Queue: Quan Nguyen <qnnguyen@chromium.org>
> Reviewed-by: Dan Erat <derat@chromium.org>
> Reviewed-by: Jacob Dufault <jdufault@chromium.org>
> Reviewed-by: Michael Wasserman <msw@chromium.org>
> Cr-Commit-Position: refs/heads/master@{#572389}

TBR=derat@chromium.org,msw@chromium.org,jdufault@chromium.org,qnnguyen@chromium.org


Bug: 845037
Change-Id: I9047f3b8d955bddc7f2d006e5da90dd30cfe98bc
Reviewed-on: https://chromium-review.googlesource.com/1130755
Commit-Queue: Ryan Hansberry <hansberry@chromium.org>
Reviewed-by: default avatarRyan Hansberry <hansberry@chromium.org>
Cr-Commit-Position: refs/heads/master@{#573571}
parent d7ae7350
...@@ -353,6 +353,8 @@ component("ash") { ...@@ -353,6 +353,8 @@ component("ash") {
"login/ui/hover_notifier.h", "login/ui/hover_notifier.h",
"login/ui/image_parser.cc", "login/ui/image_parser.cc",
"login/ui/image_parser.h", "login/ui/image_parser.h",
"login/ui/layout_util.cc",
"login/ui/layout_util.h",
"login/ui/lock_contents_view.cc", "login/ui/lock_contents_view.cc",
"login/ui/lock_contents_view.h", "login/ui/lock_contents_view.h",
"login/ui/lock_debug_view.cc", "login/ui/lock_debug_view.cc",
...@@ -397,8 +399,6 @@ component("ash") { ...@@ -397,8 +399,6 @@ component("ash") {
"login/ui/scrollable_users_list_view.h", "login/ui/scrollable_users_list_view.h",
"login/ui/user_switch_flip_animation.cc", "login/ui/user_switch_flip_animation.cc",
"login/ui/user_switch_flip_animation.h", "login/ui/user_switch_flip_animation.h",
"login/ui/views_utils.cc",
"login/ui/views_utils.h",
"login_status.h", "login_status.h",
"magnifier/docked_magnifier_controller.cc", "magnifier/docked_magnifier_controller.cc",
"magnifier/docked_magnifier_controller.h", "magnifier/docked_magnifier_controller.h",
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
#include "ash/login/ui/views_utils.h" #include "ash/login/ui/layout_util.h"
#include "ash/login/ui/non_accessible_view.h" #include "ash/login/ui/non_accessible_view.h"
#include "ash/shell.h" #include "ash/shell.h"
...@@ -11,7 +11,7 @@ ...@@ -11,7 +11,7 @@
#include "ui/views/widget/widget.h" #include "ui/views/widget/widget.h"
namespace ash { namespace ash {
namespace login_views_utils { namespace login_layout_util {
views::View* WrapViewForPreferredSize(views::View* view) { views::View* WrapViewForPreferredSize(views::View* view) {
auto* proxy = new NonAccessibleView(); auto* proxy = new NonAccessibleView();
...@@ -52,14 +52,5 @@ bool ShouldShowLandscape(const views::Widget* widget) { ...@@ -52,14 +52,5 @@ bool ShouldShowLandscape(const views::Widget* widget) {
return true; return true;
} }
bool HasFocusInAnyChildView(views::View* view) { } // namespace login_layout_util
// Find the topmost ancestor of the focused view, or |view|, whichever comes
// first.
views::View* search = view->GetFocusManager()->GetFocusedView();
while (search && search != view)
search = search->parent();
return search == view;
}
} // namespace login_views_utils
} // namespace ash } // namespace ash
...@@ -2,19 +2,19 @@ ...@@ -2,19 +2,19 @@
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
#ifndef ASH_LOGIN_UI_VIEWS_UTILS_H_ #ifndef ASH_LOGIN_UI_LAYOUT_UTIL_H_
#define ASH_LOGIN_UI_VIEWS_UTILS_H_ #define ASH_LOGIN_UI_LAYOUT_UTIL_H_
#include "ash/ash_export.h" #include "ash/ash_export.h"
namespace views { namespace views {
class View; class View;
class Widget; class Widget;
} // namespace views }
namespace ash { namespace ash {
namespace login_views_utils { namespace login_layout_util {
// Wraps view in another view so the original view is sized to it's preferred // Wraps view in another view so the original view is sized to it's preferred
// size, regardless of the view's parent's layout manager. // size, regardless of the view's parent's layout manager.
...@@ -22,12 +22,8 @@ ASH_EXPORT views::View* WrapViewForPreferredSize(views::View* view); ...@@ -22,12 +22,8 @@ ASH_EXPORT views::View* WrapViewForPreferredSize(views::View* view);
// Returns true if landscape constants should be used for UI shown in |widget|. // Returns true if landscape constants should be used for UI shown in |widget|.
ASH_EXPORT bool ShouldShowLandscape(const views::Widget* widget); ASH_EXPORT bool ShouldShowLandscape(const views::Widget* widget);
} // namespace login_layout_util
// Returns true if |view| or any of its descendant views HasFocus.
ASH_EXPORT bool HasFocusInAnyChildView(views::View* view);
} // namespace login_views_utils
} // namespace ash } // namespace ash
#endif // ASH_LOGIN_UI_VIEWS_UTILS_H_ #endif // ASH_LOGIN_UI_LAYOUT_UTIL_H_
...@@ -13,6 +13,7 @@ ...@@ -13,6 +13,7 @@
#include "ash/focus_cycler.h" #include "ash/focus_cycler.h"
#include "ash/ime/ime_controller.h" #include "ash/ime/ime_controller.h"
#include "ash/login/login_screen_controller.h" #include "ash/login/login_screen_controller.h"
#include "ash/login/ui/layout_util.h"
#include "ash/login/ui/lock_screen.h" #include "ash/login/ui/lock_screen.h"
#include "ash/login/ui/login_auth_user_view.h" #include "ash/login/ui/login_auth_user_view.h"
#include "ash/login/ui/login_big_user_view.h" #include "ash/login/ui/login_big_user_view.h"
...@@ -24,7 +25,6 @@ ...@@ -24,7 +25,6 @@
#include "ash/login/ui/non_accessible_view.h" #include "ash/login/ui/non_accessible_view.h"
#include "ash/login/ui/note_action_launch_button.h" #include "ash/login/ui/note_action_launch_button.h"
#include "ash/login/ui/scrollable_users_list_view.h" #include "ash/login/ui/scrollable_users_list_view.h"
#include "ash/login/ui/views_utils.h"
#include "ash/root_window_controller.h" #include "ash/root_window_controller.h"
#include "ash/shelf/shelf.h" #include "ash/shelf/shelf.h"
#include "ash/shelf/shelf_widget.h" #include "ash/shelf/shelf_widget.h"
...@@ -331,74 +331,6 @@ LockContentsView::~LockContentsView() { ...@@ -331,74 +331,6 @@ LockContentsView::~LockContentsView() {
this); this);
} }
void LockContentsView::FocusNextUser() {
if (login_views_utils::HasFocusInAnyChildView(primary_big_view_)) {
if (opt_secondary_big_view_) {
SwapActiveAuthBetweenPrimaryAndSecondary(false /*is_primary*/);
opt_secondary_big_view_->RequestFocus();
} else if (users_list_) {
users_list_->user_view_at(0)->RequestFocus();
}
return;
}
if (opt_secondary_big_view_ &&
login_views_utils::HasFocusInAnyChildView(opt_secondary_big_view_)) {
SwapActiveAuthBetweenPrimaryAndSecondary(true /*is_primary*/);
primary_big_view_->RequestFocus();
return;
}
for (int i = 0; i < users_list_->user_count(); ++i) {
LoginUserView* user_view = users_list_->user_view_at(i);
if (!login_views_utils::HasFocusInAnyChildView(user_view))
continue;
if (i == users_list_->user_count() - 1) {
SwapActiveAuthBetweenPrimaryAndSecondary(true /*is_primary*/);
primary_big_view_->RequestFocus();
return;
}
user_view->GetNextFocusableView()->RequestFocus();
return;
}
}
void LockContentsView::FocusPreviousUser() {
if (login_views_utils::HasFocusInAnyChildView(primary_big_view_)) {
if (users_list_) {
users_list_->user_view_at(users_list_->user_count() - 1)->RequestFocus();
} else if (opt_secondary_big_view_) {
SwapActiveAuthBetweenPrimaryAndSecondary(false /*is_primary*/);
opt_secondary_big_view_->RequestFocus();
}
return;
}
if (opt_secondary_big_view_ &&
login_views_utils::HasFocusInAnyChildView(opt_secondary_big_view_)) {
SwapActiveAuthBetweenPrimaryAndSecondary(true /*is_primary*/);
primary_big_view_->RequestFocus();
return;
}
for (int i = 0; i < users_list_->user_count(); ++i) {
LoginUserView* user_view = users_list_->user_view_at(i);
if (!login_views_utils::HasFocusInAnyChildView(user_view))
continue;
if (i == 0) {
SwapActiveAuthBetweenPrimaryAndSecondary(true /*is_primary*/);
primary_big_view_->RequestFocus();
return;
}
user_view->GetPreviousFocusableView()->RequestFocus();
return;
}
}
void LockContentsView::Layout() { void LockContentsView::Layout() {
View::Layout(); View::Layout();
LayoutTopHeader(); LayoutTopHeader();
...@@ -950,7 +882,7 @@ void LockContentsView::CreateHighDensityLayout( ...@@ -950,7 +882,7 @@ void LockContentsView::CreateHighDensityLayout(
} }
void LockContentsView::DoLayout() { void LockContentsView::DoLayout() {
bool landscape = login_views_utils::ShouldShowLandscape(GetWidget()); bool landscape = login_layout_util::ShouldShowLandscape(GetWidget());
for (auto& action : rotation_actions_) for (auto& action : rotation_actions_)
action.Run(landscape); action.Run(landscape);
...@@ -993,7 +925,7 @@ views::View* LockContentsView::MakeOrientationViewWithWidths(int landscape, ...@@ -993,7 +925,7 @@ views::View* LockContentsView::MakeOrientationViewWithWidths(int landscape,
} }
void LockContentsView::AddRotationAction(const OnRotate& on_rotate) { void LockContentsView::AddRotationAction(const OnRotate& on_rotate) {
on_rotate.Run(login_views_utils::ShouldShowLandscape(GetWidget())); on_rotate.Run(login_layout_util::ShouldShowLandscape(GetWidget()));
rotation_actions_.push_back(on_rotate); rotation_actions_.push_back(on_rotate);
} }
...@@ -1113,6 +1045,7 @@ void LockContentsView::OnBigUserChanged() { ...@@ -1113,6 +1045,7 @@ void LockContentsView::OnBigUserChanged() {
CurrentBigUserView()->RequestFocus(); CurrentBigUserView()->RequestFocus();
Shell::Get()->login_screen_controller()->OnFocusPod(new_big_user);
UpdateEasyUnlockIconForUser(new_big_user); UpdateEasyUnlockIconForUser(new_big_user);
if (unlock_attempt_ > 0) { if (unlock_attempt_ > 0) {
...@@ -1129,9 +1062,6 @@ void LockContentsView::OnBigUserChanged() { ...@@ -1129,9 +1062,6 @@ void LockContentsView::OnBigUserChanged() {
// sure the detachable base pairing error is updated if needed. // sure the detachable base pairing error is updated if needed.
OnDetachableBasePairingStatusChanged( OnDetachableBasePairingStatusChanged(
detachable_base_model_->GetPairingStatus()); detachable_base_model_->GetPairingStatus());
if (!detachable_base_error_bubble_->IsVisible())
CurrentBigUserView()->RequestFocus();
} }
void LockContentsView::UpdateEasyUnlockIconForUser(const AccountId& user) { void LockContentsView::UpdateEasyUnlockIconForUser(const AccountId& user) {
...@@ -1425,10 +1355,6 @@ void LockContentsView::RegisterAccelerators() { ...@@ -1425,10 +1355,6 @@ void LockContentsView::RegisterAccelerators() {
// TODO: Add more accelerators that are applicable to login screen. // TODO: Add more accelerators that are applicable to login screen.
accel_map_[ui::Accelerator(ui::VKEY_I, ui::EF_SHIFT_DOWN | ui::EF_ALT_DOWN)] = accel_map_[ui::Accelerator(ui::VKEY_I, ui::EF_SHIFT_DOWN | ui::EF_ALT_DOWN)] =
AcceleratorAction::kShowFeedback; AcceleratorAction::kShowFeedback;
accel_map_[ui::Accelerator(ui::VKEY_RIGHT, 0)] =
AcceleratorAction::kFocusNextUser;
accel_map_[ui::Accelerator(ui::VKEY_LEFT, 0)] =
AcceleratorAction::kFocusPreviousUser;
AcceleratorController* controller = Shell::Get()->accelerator_controller(); AcceleratorController* controller = Shell::Get()->accelerator_controller();
for (const auto& item : accel_map_) for (const auto& item : accel_map_)
...@@ -1440,12 +1366,6 @@ void LockContentsView::PerformAction(AcceleratorAction action) { ...@@ -1440,12 +1366,6 @@ void LockContentsView::PerformAction(AcceleratorAction action) {
case AcceleratorAction::kShowFeedback: case AcceleratorAction::kShowFeedback:
Shell::Get()->login_screen_controller()->ShowFeedback(); Shell::Get()->login_screen_controller()->ShowFeedback();
return; return;
case AcceleratorAction::kFocusNextUser:
FocusNextUser();
return;
case AcceleratorAction::kFocusPreviousUser:
FocusPreviousUser();
return;
default: default:
NOTREACHED(); NOTREACHED();
} }
......
...@@ -102,8 +102,6 @@ class ASH_EXPORT LockContentsView ...@@ -102,8 +102,6 @@ class ASH_EXPORT LockContentsView
enum class AcceleratorAction { enum class AcceleratorAction {
kShowFeedback, kShowFeedback,
kFocusNextUser,
kFocusPreviousUser,
}; };
// Number of login attempts before a login dialog is shown. For example, if // Number of login attempts before a login dialog is shown. For example, if
...@@ -119,9 +117,6 @@ class ASH_EXPORT LockContentsView ...@@ -119,9 +117,6 @@ class ASH_EXPORT LockContentsView
std::unique_ptr<LoginDetachableBaseModel> detachable_base_model); std::unique_ptr<LoginDetachableBaseModel> detachable_base_model);
~LockContentsView() override; ~LockContentsView() override;
void FocusNextUser();
void FocusPreviousUser();
// views::View: // views::View:
void Layout() override; void Layout() override;
void AddedToWidget() override; void AddedToWidget() override;
......
...@@ -25,7 +25,6 @@ ...@@ -25,7 +25,6 @@
#include "ash/login/ui/login_test_utils.h" #include "ash/login/ui/login_test_utils.h"
#include "ash/login/ui/login_user_view.h" #include "ash/login/ui/login_user_view.h"
#include "ash/login/ui/scrollable_users_list_view.h" #include "ash/login/ui/scrollable_users_list_view.h"
#include "ash/login/ui/views_utils.h"
#include "ash/public/interfaces/tray_action.mojom.h" #include "ash/public/interfaces/tray_action.mojom.h"
#include "ash/shell.h" #include "ash/shell.h"
#include "base/strings/utf_string_conversions.h" #include "base/strings/utf_string_conversions.h"
...@@ -1393,37 +1392,6 @@ TEST_F(LockContentsViewUnitTest, UserListUserSwapFocusesPassword) { ...@@ -1393,37 +1392,6 @@ TEST_F(LockContentsViewUnitTest, UserListUserSwapFocusesPassword) {
EXPECT_TRUE(HasFocusInAnyChildView(password_view)); EXPECT_TRUE(HasFocusInAnyChildView(password_view));
} }
TEST_F(LockContentsViewUnitTest, BadDetachableBaseUnfocusesPasswordView) {
auto fake_detachable_base_model =
std::make_unique<FakeLoginDetachableBaseModel>(data_dispatcher());
FakeLoginDetachableBaseModel* detachable_base_model =
fake_detachable_base_model.get();
auto* contents = new LockContentsView(
mojom::TrayActionState::kNotAvailable, LockScreen::ScreenType::kLock,
data_dispatcher(), std::move(fake_detachable_base_model));
SetUserCount(3);
std::unique_ptr<views::Widget> widget = CreateWidgetWithContent(contents);
LockContentsView::TestApi test_api(contents);
LoginBigUserView* primary_view = test_api.primary_big_view();
LoginPasswordView* primary_password_view =
LoginAuthUserView::TestApi(primary_view->auth_user()).password_view();
EXPECT_TRUE(login_views_utils::HasFocusInAnyChildView(primary_password_view));
detachable_base_model->SetPairingStatus(
DetachableBasePairingStatus::kNotAuthenticated, "");
EXPECT_FALSE(
login_views_utils::HasFocusInAnyChildView(primary_password_view));
// Swapping to another user should still not focus password view.
LoginUserView* first_list_user = test_api.users_list()->user_view_at(0);
first_list_user->RequestFocus();
GetEventGenerator()->PressKey(ui::KeyboardCode::VKEY_RETURN, 0);
EXPECT_FALSE(
login_views_utils::HasFocusInAnyChildView(primary_password_view));
}
TEST_F(LockContentsViewUnitTest, ExpandedPublicSessionView) { TEST_F(LockContentsViewUnitTest, ExpandedPublicSessionView) {
// Build lock screen with 3 users: one public account user and two regular // Build lock screen with 3 users: one public account user and two regular
// users. // users.
...@@ -1582,102 +1550,4 @@ TEST_F(LockContentsViewKeyboardUnitTest, PasswordClearedOnSuspend) { ...@@ -1582,102 +1550,4 @@ TEST_F(LockContentsViewKeyboardUnitTest, PasswordClearedOnSuspend) {
EXPECT_TRUE(textfield->text().empty()); EXPECT_TRUE(textfield->text().empty());
} }
TEST_F(LockContentsViewKeyboardUnitTest, ArrowNavSingleUser) {
ASSERT_NO_FATAL_FAILURE(ShowLoginScreen());
LoadUsers(1);
LockContentsView* lock_contents =
LockScreen::TestApi(LockScreen::Get()).contents_view();
LoginBigUserView* primary_big_view =
LockContentsView::TestApi(lock_contents).primary_big_view();
EXPECT_TRUE(login_views_utils::HasFocusInAnyChildView(primary_big_view));
ui::test::EventGenerator* generator = GetEventGenerator();
generator->PressKey(ui::VKEY_RIGHT, 0);
EXPECT_TRUE(login_views_utils::HasFocusInAnyChildView(primary_big_view));
generator->PressKey(ui::VKEY_LEFT, 0);
EXPECT_TRUE(login_views_utils::HasFocusInAnyChildView(primary_big_view));
}
TEST_F(LockContentsViewKeyboardUnitTest, ArrowNavTwoUsers) {
ASSERT_NO_FATAL_FAILURE(ShowLoginScreen());
LoadUsers(1);
LoadPublicAccountUsers(1);
LockContentsView::TestApi lock_contents = LockContentsView::TestApi(
LockScreen::TestApi(LockScreen::Get()).contents_view());
LoginPasswordView* primary_password_view =
LoginAuthUserView::TestApi(lock_contents.primary_big_view()->auth_user())
.password_view();
LoginBigUserView* secondary_user_view =
lock_contents.opt_secondary_big_view();
ASSERT_NE(nullptr, secondary_user_view);
EXPECT_TRUE(login_views_utils::HasFocusInAnyChildView(primary_password_view));
ui::test::EventGenerator* generator = GetEventGenerator();
generator->PressKey(ui::VKEY_RIGHT, 0);
EXPECT_TRUE(login_views_utils::HasFocusInAnyChildView(secondary_user_view));
generator->PressKey(ui::VKEY_RIGHT, 0);
EXPECT_TRUE(login_views_utils::HasFocusInAnyChildView(primary_password_view));
generator->PressKey(ui::VKEY_LEFT, 0);
EXPECT_TRUE(login_views_utils::HasFocusInAnyChildView(secondary_user_view));
generator->PressKey(ui::VKEY_LEFT, 0);
EXPECT_TRUE(login_views_utils::HasFocusInAnyChildView(primary_password_view));
}
TEST_F(LockContentsViewKeyboardUnitTest, ArrowNavThreeUsers) {
ASSERT_NO_FATAL_FAILURE(ShowLoginScreen());
LoadUsers(3);
LockContentsView::TestApi lock_contents = LockContentsView::TestApi(
LockScreen::TestApi(LockScreen::Get()).contents_view());
LoginPasswordView* primary_password_view =
LoginAuthUserView::TestApi(lock_contents.primary_big_view()->auth_user())
.password_view();
LoginUserView* first_list_user = lock_contents.users_list()->user_view_at(0);
LoginUserView* second_list_user = lock_contents.users_list()->user_view_at(1);
EXPECT_TRUE(login_views_utils::HasFocusInAnyChildView(primary_password_view));
ui::test::EventGenerator* generator = GetEventGenerator();
generator->PressKey(ui::VKEY_RIGHT, 0);
EXPECT_TRUE(login_views_utils::HasFocusInAnyChildView(first_list_user));
generator->PressKey(ui::VKEY_RIGHT, 0);
EXPECT_TRUE(login_views_utils::HasFocusInAnyChildView(second_list_user));
generator->PressKey(ui::VKEY_RIGHT, 0);
EXPECT_TRUE(login_views_utils::HasFocusInAnyChildView(primary_password_view));
generator->PressKey(ui::VKEY_LEFT, 0);
EXPECT_TRUE(login_views_utils::HasFocusInAnyChildView(second_list_user));
generator->PressKey(ui::VKEY_LEFT, 0);
EXPECT_TRUE(login_views_utils::HasFocusInAnyChildView(first_list_user));
generator->PressKey(ui::VKEY_LEFT, 0);
EXPECT_TRUE(login_views_utils::HasFocusInAnyChildView(primary_password_view));
}
TEST_F(LockContentsViewKeyboardUnitTest, UserSwapFocusesBigView) {
ASSERT_NO_FATAL_FAILURE(ShowLoginScreen());
LoadUsers(3);
LockContentsView::TestApi lock_contents = LockContentsView::TestApi(
LockScreen::TestApi(LockScreen::Get()).contents_view());
LoginPasswordView* primary_password_view =
LoginAuthUserView::TestApi(lock_contents.primary_big_view()->auth_user())
.password_view();
EXPECT_TRUE(login_views_utils::HasFocusInAnyChildView(primary_password_view));
lock_contents.users_list()->user_view_at(0)->RequestFocus();
ui::test::EventGenerator* generator = GetEventGenerator();
generator->PressKey(ui::VKEY_RETURN, 0);
EXPECT_TRUE(login_views_utils::HasFocusInAnyChildView(primary_password_view));
}
} // namespace ash } // namespace ash
...@@ -12,12 +12,12 @@ ...@@ -12,12 +12,12 @@
#include "ash/detachable_base/detachable_base_pairing_status.h" #include "ash/detachable_base/detachable_base_pairing_status.h"
#include "ash/ime/ime_controller.h" #include "ash/ime/ime_controller.h"
#include "ash/login/login_screen_controller.h" #include "ash/login/login_screen_controller.h"
#include "ash/login/ui/layout_util.h"
#include "ash/login/ui/lock_contents_view.h" #include "ash/login/ui/lock_contents_view.h"
#include "ash/login/ui/lock_screen.h" #include "ash/login/ui/lock_screen.h"
#include "ash/login/ui/login_data_dispatcher.h" #include "ash/login/ui/login_data_dispatcher.h"
#include "ash/login/ui/login_detachable_base_model.h" #include "ash/login/ui/login_detachable_base_model.h"
#include "ash/login/ui/non_accessible_view.h" #include "ash/login/ui/non_accessible_view.h"
#include "ash/login/ui/views_utils.h"
#include "ash/public/interfaces/kiosk_app_info.mojom.h" #include "ash/public/interfaces/kiosk_app_info.mojom.h"
#include "ash/shelf/shelf.h" #include "ash/shelf/shelf.h"
#include "ash/shelf/shelf_widget.h" #include "ash/shelf/shelf_widget.h"
...@@ -835,7 +835,7 @@ views::LabelButton* LockDebugView::AddButton(const std::string& text, ...@@ -835,7 +835,7 @@ views::LabelButton* LockDebugView::AddButton(const std::string& text,
this, base::ASCIIToUTF16(text)); this, base::ASCIIToUTF16(text));
button->set_id(id); button->set_id(id);
button->SetFocusBehavior(views::View::FocusBehavior::NEVER); button->SetFocusBehavior(views::View::FocusBehavior::NEVER);
container->AddChildView(login_views_utils::WrapViewForPreferredSize(button)); container->AddChildView(login_layout_util::WrapViewForPreferredSize(button));
return button; return button;
} }
......
...@@ -170,14 +170,6 @@ LoginDataDispatcher* LockScreen::data_dispatcher() { ...@@ -170,14 +170,6 @@ LoginDataDispatcher* LockScreen::data_dispatcher() {
return window_->data_dispatcher(); return window_->data_dispatcher();
} }
void LockScreen::FocusNextUser() {
contents_view_->FocusNextUser();
}
void LockScreen::FocusPreviousUser() {
contents_view_->FocusPreviousUser();
}
void LockScreen::OnLockScreenNoteStateChanged(mojom::TrayActionState state) { void LockScreen::OnLockScreenNoteStateChanged(mojom::TrayActionState state) {
if (data_dispatcher()) if (data_dispatcher())
data_dispatcher()->SetLockScreenNoteState(state); data_dispatcher()->SetLockScreenNoteState(state);
......
...@@ -74,9 +74,6 @@ class ASH_EXPORT LockScreen : public TrayActionObserver, ...@@ -74,9 +74,6 @@ class ASH_EXPORT LockScreen : public TrayActionObserver,
// Returns if the screen has been shown (i.e. |LockWindow::Show| was called). // Returns if the screen has been shown (i.e. |LockWindow::Show| was called).
bool is_shown() const { return is_shown_; } bool is_shown() const { return is_shown_; }
void FocusNextUser();
void FocusPreviousUser();
// TrayActionObserver: // TrayActionObserver:
void OnLockScreenNoteStateChanged(mojom::TrayActionState state) override; void OnLockScreenNoteStateChanged(mojom::TrayActionState state) override;
......
...@@ -8,6 +8,7 @@ ...@@ -8,6 +8,7 @@
#include <memory> #include <memory>
#include "ash/login/login_screen_controller.h" #include "ash/login/login_screen_controller.h"
#include "ash/login/ui/layout_util.h"
#include "ash/login/ui/lock_screen.h" #include "ash/login/ui/lock_screen.h"
#include "ash/login/ui/login_display_style.h" #include "ash/login/ui/login_display_style.h"
#include "ash/login/ui/login_password_view.h" #include "ash/login/ui/login_password_view.h"
...@@ -15,7 +16,6 @@ ...@@ -15,7 +16,6 @@
#include "ash/login/ui/login_user_view.h" #include "ash/login/ui/login_user_view.h"
#include "ash/login/ui/non_accessible_view.h" #include "ash/login/ui/non_accessible_view.h"
#include "ash/login/ui/pin_keyboard_animation.h" #include "ash/login/ui/pin_keyboard_animation.h"
#include "ash/login/ui/views_utils.h"
#include "ash/public/cpp/login_constants.h" #include "ash/public/cpp/login_constants.h"
#include "ash/resources/vector_icons/vector_icons.h" #include "ash/resources/vector_icons/vector_icons.h"
#include "ash/shell.h" #include "ash/shell.h"
...@@ -404,17 +404,17 @@ LoginAuthUserView::LoginAuthUserView(const mojom::LoginUserInfoPtr& user, ...@@ -404,17 +404,17 @@ LoginAuthUserView::LoginAuthUserView(const mojom::LoginUserInfoPtr& user,
// Build layout. // Build layout.
auto* wrapped_password_view = auto* wrapped_password_view =
login_views_utils::WrapViewForPreferredSize(password_view_); login_layout_util::WrapViewForPreferredSize(password_view_);
auto* wrapped_online_sign_in_message_view = auto* wrapped_online_sign_in_message_view =
login_views_utils::WrapViewForPreferredSize(online_sign_in_message_); login_layout_util::WrapViewForPreferredSize(online_sign_in_message_);
auto* wrapped_disabled_auth_message_view = auto* wrapped_disabled_auth_message_view =
login_views_utils::WrapViewForPreferredSize(disabled_auth_message_); login_layout_util::WrapViewForPreferredSize(disabled_auth_message_);
auto* wrapped_user_view = auto* wrapped_user_view =
login_views_utils::WrapViewForPreferredSize(user_view_); login_layout_util::WrapViewForPreferredSize(user_view_);
auto* wrapped_pin_view = auto* wrapped_pin_view =
login_views_utils::WrapViewForPreferredSize(pin_view_); login_layout_util::WrapViewForPreferredSize(pin_view_);
auto* wrapped_fingerprint_view = auto* wrapped_fingerprint_view =
login_views_utils::WrapViewForPreferredSize(fingerprint_view_); login_layout_util::WrapViewForPreferredSize(fingerprint_view_);
// Add views in tabbing order; they are rendered in a different order below. // Add views in tabbing order; they are rendered in a different order below.
AddChildView(wrapped_password_view); AddChildView(wrapped_password_view);
......
...@@ -8,12 +8,12 @@ ...@@ -8,12 +8,12 @@
#include <utility> #include <utility>
#include "ash/focus_cycler.h" #include "ash/focus_cycler.h"
#include "ash/login/ui/layout_util.h"
#include "ash/login/ui/lock_screen.h" #include "ash/login/ui/lock_screen.h"
#include "ash/login/ui/lock_window.h" #include "ash/login/ui/lock_window.h"
#include "ash/login/ui/login_button.h" #include "ash/login/ui/login_button.h"
#include "ash/login/ui/login_menu_view.h" #include "ash/login/ui/login_menu_view.h"
#include "ash/login/ui/non_accessible_view.h" #include "ash/login/ui/non_accessible_view.h"
#include "ash/login/ui/views_utils.h"
#include "ash/public/cpp/ash_constants.h" #include "ash/public/cpp/ash_constants.h"
#include "ash/resources/vector_icons/vector_icons.h" #include "ash/resources/vector_icons/vector_icons.h"
#include "ash/shell.h" #include "ash/shell.h"
......
...@@ -99,26 +99,19 @@ void LoginKeyboardTestBase::ShowLoginScreen() { ...@@ -99,26 +99,19 @@ void LoginKeyboardTestBase::ShowLoginScreen() {
} }
void LoginKeyboardTestBase::LoadUsers(int count) { void LoginKeyboardTestBase::LoadUsers(int count) {
std::vector<mojom::LoginUserInfoPtr> users;
for (int i = 0; i < count; ++i) { for (int i = 0; i < count; ++i) {
std::string email = std::string email =
base::StrCat({"user", std::to_string(i), "@domain.com "}); base::StrCat({"user", std::to_string(i), "@domain.com "});
users_.push_back(CreateUser(email)); users.push_back(CreateUser(email));
} }
ash::LockScreen::Get()->data_dispatcher()->NotifyUsers(users_); login_controller_->LoadUsers(std::move(users), false);
}
void LoginKeyboardTestBase::LoadPublicAccountUsers(int count) {
for (int i = 0; i < count; ++i) {
std::string email =
base::StrCat({"publicuser", std::to_string(i), "@domain.com"});
users_.push_back(CreatePublicAccountUser(email));
}
ash::LockScreen::Get()->data_dispatcher()->NotifyUsers(users_);
} }
void LoginKeyboardTestBase::LoadUser(const std::string& email) { void LoginKeyboardTestBase::LoadUser(const std::string& email) {
users_.push_back(CreateUser(email)); std::vector<mojom::LoginUserInfoPtr> users;
ash::LockScreen::Get()->data_dispatcher()->NotifyUsers(users_); users.push_back(CreateUser(email));
login_controller_->LoadUsers(std::move(users), false);
} }
} // namespace ash } // namespace ash
...@@ -7,7 +7,6 @@ ...@@ -7,7 +7,6 @@
#include <memory> #include <memory>
#include "ash/public/interfaces/login_user_info.mojom.h"
#include "ash/test/ash_test_base.h" #include "ash/test/ash_test_base.h"
namespace keyboard { namespace keyboard {
...@@ -48,9 +47,6 @@ class LoginKeyboardTestBase : public AshTestBase { ...@@ -48,9 +47,6 @@ class LoginKeyboardTestBase : public AshTestBase {
// Loads the number of test users specified by |count|. // Loads the number of test users specified by |count|.
void LoadUsers(int count); void LoadUsers(int count);
// Loads the number of test public account users specified by |count|.
void LoadPublicAccountUsers(int count);
// Loads user with the specified |email|. // Loads user with the specified |email|.
void LoadUser(const std::string& email); void LoadUser(const std::string& email);
...@@ -61,7 +57,6 @@ class LoginKeyboardTestBase : public AshTestBase { ...@@ -61,7 +57,6 @@ class LoginKeyboardTestBase : public AshTestBase {
private: private:
keyboard::KeyboardController* keyboard_controller_ = nullptr; keyboard::KeyboardController* keyboard_controller_ = nullptr;
LoginScreenController* login_controller_ = nullptr; LoginScreenController* login_controller_ = nullptr;
std::vector<mojom::LoginUserInfoPtr> users_;
DISALLOW_COPY_AND_ASSIGN(LoginKeyboardTestBase); DISALLOW_COPY_AND_ASSIGN(LoginKeyboardTestBase);
}; };
......
...@@ -5,7 +5,6 @@ ...@@ -5,7 +5,6 @@
#include "ash/login/ui/login_password_view.h" #include "ash/login/ui/login_password_view.h"
#include "ash/login/ui/hover_notifier.h" #include "ash/login/ui/hover_notifier.h"
#include "ash/login/ui/lock_screen.h"
#include "ash/login/ui/login_button.h" #include "ash/login/ui/login_button.h"
#include "ash/login/ui/non_accessible_view.h" #include "ash/login/ui/non_accessible_view.h"
#include "ash/public/cpp/login_constants.h" #include "ash/public/cpp/login_constants.h"
...@@ -584,33 +583,6 @@ void LoginPasswordView::ContentsChanged(views::Textfield* sender, ...@@ -584,33 +583,6 @@ void LoginPasswordView::ContentsChanged(views::Textfield* sender,
on_password_text_changed_.Run(new_contents.empty() /*is_empty*/); on_password_text_changed_.Run(new_contents.empty() /*is_empty*/);
} }
// Implements swapping active user with arrow keys
bool LoginPasswordView::HandleKeyEvent(views::Textfield* sender,
const ui::KeyEvent& key_event) {
// Treat the password field as normal if it has text
if (!textfield_->text().empty())
return false;
if (key_event.type() != ui::ET_KEY_PRESSED)
return false;
if (key_event.is_repeat())
return false;
switch (key_event.key_code()) {
case ui::VKEY_LEFT:
LockScreen::Get()->FocusPreviousUser();
break;
case ui::VKEY_RIGHT:
LockScreen::Get()->FocusNextUser();
break;
default:
return false;
}
return true;
}
void LoginPasswordView::UpdateUiState() { void LoginPasswordView::UpdateUiState() {
bool is_enabled = !textfield_->text().empty() && !textfield_->read_only(); bool is_enabled = !textfield_->text().empty() && !textfield_->read_only();
submit_button_->SetEnabled(is_enabled); submit_button_->SetEnabled(is_enabled);
......
...@@ -8,7 +8,6 @@ ...@@ -8,7 +8,6 @@
#include "ash/ash_export.h" #include "ash/ash_export.h"
#include "ash/ime/ime_controller.h" #include "ash/ime/ime_controller.h"
#include "ash/login/ui/animated_rounded_image_view.h" #include "ash/login/ui/animated_rounded_image_view.h"
#include "ash/login/ui/lock_screen.h"
#include "ash/public/interfaces/login_user_info.mojom.h" #include "ash/public/interfaces/login_user_info.mojom.h"
#include "ash/public/interfaces/user_info.mojom.h" #include "ash/public/interfaces/user_info.mojom.h"
#include "base/scoped_observer.h" #include "base/scoped_observer.h"
...@@ -116,8 +115,6 @@ class ASH_EXPORT LoginPasswordView : public views::View, ...@@ -116,8 +115,6 @@ class ASH_EXPORT LoginPasswordView : public views::View,
// views::TextfieldController: // views::TextfieldController:
void ContentsChanged(views::Textfield* sender, void ContentsChanged(views::Textfield* sender,
const base::string16& new_contents) override; const base::string16& new_contents) override;
bool HandleKeyEvent(views::Textfield* sender,
const ui::KeyEvent& key_event) override;
// ImeController::Observer: // ImeController::Observer:
void OnCapsLockChanged(bool enabled) override; void OnCapsLockChanged(bool enabled) override;
......
...@@ -8,8 +8,8 @@ ...@@ -8,8 +8,8 @@
#include "ash/login/ui/arrow_button_view.h" #include "ash/login/ui/arrow_button_view.h"
#include "ash/login/ui/hover_notifier.h" #include "ash/login/ui/hover_notifier.h"
#include "ash/login/ui/layout_util.h"
#include "ash/login/ui/login_display_style.h" #include "ash/login/ui/login_display_style.h"
#include "ash/login/ui/views_utils.h"
#include "ui/compositor/scoped_layer_animation_settings.h" #include "ui/compositor/scoped_layer_animation_settings.h"
#include "ui/views/layout/box_layout.h" #include "ui/views/layout/box_layout.h"
...@@ -74,7 +74,7 @@ LoginPublicAccountUserView::LoginPublicAccountUserView( ...@@ -74,7 +74,7 @@ LoginPublicAccountUserView::LoginPublicAccountUserView(
SetLayoutManager( SetLayoutManager(
std::make_unique<views::BoxLayout>(views::BoxLayout::kVertical)); std::make_unique<views::BoxLayout>(views::BoxLayout::kVertical));
views::View* wrapped_user_view = views::View* wrapped_user_view =
login_views_utils::WrapViewForPreferredSize(user_view_); login_layout_util::WrapViewForPreferredSize(user_view_);
auto add_padding = [&](int amount) { auto add_padding = [&](int amount) {
auto* padding = new NonAccessibleView(); auto* padding = new NonAccessibleView();
......
...@@ -9,17 +9,15 @@ ...@@ -9,17 +9,15 @@
#include "ash/login/ui/animated_rounded_image_view.h" #include "ash/login/ui/animated_rounded_image_view.h"
#include "ash/login/ui/hover_notifier.h" #include "ash/login/ui/hover_notifier.h"
#include "ash/login/ui/image_parser.h" #include "ash/login/ui/image_parser.h"
#include "ash/login/ui/lock_screen.h" #include "ash/login/ui/layout_util.h"
#include "ash/login/ui/login_bubble.h" #include "ash/login/ui/login_bubble.h"
#include "ash/login/ui/login_button.h" #include "ash/login/ui/login_button.h"
#include "ash/login/ui/non_accessible_view.h" #include "ash/login/ui/non_accessible_view.h"
#include "ash/login/ui/user_switch_flip_animation.h" #include "ash/login/ui/user_switch_flip_animation.h"
#include "ash/login/ui/views_utils.h"
#include "ash/public/cpp/ash_constants.h" #include "ash/public/cpp/ash_constants.h"
#include "ash/public/cpp/login_constants.h" #include "ash/public/cpp/login_constants.h"
#include "ash/public/interfaces/user_info.mojom.h" #include "ash/public/interfaces/user_info.mojom.h"
#include "ash/resources/vector_icons/vector_icons.h" #include "ash/resources/vector_icons/vector_icons.h"
#include "ash/shell.h"
#include "ash/strings/grit/ash_strings.h" #include "ash/strings/grit/ash_strings.h"
#include "ash/system/user/rounded_image_view.h" #include "ash/system/user/rounded_image_view.h"
#include "base/memory/weak_ptr.h" #include "base/memory/weak_ptr.h"
......
...@@ -7,8 +7,8 @@ ...@@ -7,8 +7,8 @@
#include <memory> #include <memory>
#include <vector> #include <vector>
#include "ash/login/ui/layout_util.h"
#include "ash/login/ui/login_test_base.h" #include "ash/login/ui/login_test_base.h"
#include "ash/login/ui/views_utils.h"
#include "ash/public/interfaces/tray_action.mojom.h" #include "ash/public/interfaces/tray_action.mojom.h"
#include "ash/shell.h" #include "ash/shell.h"
#include "ash/tray_action/test_tray_action_client.h" #include "ash/tray_action/test_tray_action_client.h"
...@@ -101,7 +101,7 @@ TEST_F(NoteActionLaunchButtonTest, KeyboardTest) { ...@@ -101,7 +101,7 @@ TEST_F(NoteActionLaunchButtonTest, KeyboardTest) {
auto* note_action_button = auto* note_action_button =
new NoteActionLaunchButton(mojom::TrayActionState::kAvailable); new NoteActionLaunchButton(mojom::TrayActionState::kAvailable);
std::unique_ptr<views::Widget> widget = CreateWidgetWithContent( std::unique_ptr<views::Widget> widget = CreateWidgetWithContent(
login_views_utils::WrapViewForPreferredSize(note_action_button)); login_layout_util::WrapViewForPreferredSize(note_action_button));
NoteActionLaunchButton::TestApi test_api(note_action_button); NoteActionLaunchButton::TestApi test_api(note_action_button);
note_action_button->RequestFocus(); note_action_button->RequestFocus();
...@@ -126,7 +126,7 @@ TEST_F(NoteActionLaunchButtonTest, ClickTest) { ...@@ -126,7 +126,7 @@ TEST_F(NoteActionLaunchButtonTest, ClickTest) {
auto* note_action_button = auto* note_action_button =
new NoteActionLaunchButton(mojom::TrayActionState::kAvailable); new NoteActionLaunchButton(mojom::TrayActionState::kAvailable);
std::unique_ptr<views::Widget> widget = CreateWidgetWithContent( std::unique_ptr<views::Widget> widget = CreateWidgetWithContent(
login_views_utils::WrapViewForPreferredSize(note_action_button)); login_layout_util::WrapViewForPreferredSize(note_action_button));
const gfx::Size action_size = note_action_button->GetPreferredSize(); const gfx::Size action_size = note_action_button->GetPreferredSize();
EXPECT_EQ(gfx::Size(kLargeButtonRadiusDp, kLargeButtonRadiusDp), action_size); EXPECT_EQ(gfx::Size(kLargeButtonRadiusDp, kLargeButtonRadiusDp), action_size);
...@@ -238,7 +238,7 @@ TEST_F(NoteActionLaunchButtonTest, TapTest) { ...@@ -238,7 +238,7 @@ TEST_F(NoteActionLaunchButtonTest, TapTest) {
auto* note_action_button = auto* note_action_button =
new NoteActionLaunchButton(mojom::TrayActionState::kAvailable); new NoteActionLaunchButton(mojom::TrayActionState::kAvailable);
std::unique_ptr<views::Widget> widget = CreateWidgetWithContent( std::unique_ptr<views::Widget> widget = CreateWidgetWithContent(
login_views_utils::WrapViewForPreferredSize(note_action_button)); login_layout_util::WrapViewForPreferredSize(note_action_button));
const gfx::Size action_size = note_action_button->GetPreferredSize(); const gfx::Size action_size = note_action_button->GetPreferredSize();
EXPECT_EQ(gfx::Size(kLargeButtonRadiusDp, kLargeButtonRadiusDp), action_size); EXPECT_EQ(gfx::Size(kLargeButtonRadiusDp, kLargeButtonRadiusDp), action_size);
...@@ -273,7 +273,7 @@ TEST_F(NoteActionLaunchButtonTest, FlingGesture) { ...@@ -273,7 +273,7 @@ TEST_F(NoteActionLaunchButtonTest, FlingGesture) {
auto* note_action_button = auto* note_action_button =
new NoteActionLaunchButton(mojom::TrayActionState::kAvailable); new NoteActionLaunchButton(mojom::TrayActionState::kAvailable);
std::unique_ptr<views::Widget> widget = CreateWidgetWithContent( std::unique_ptr<views::Widget> widget = CreateWidgetWithContent(
login_views_utils::WrapViewForPreferredSize(note_action_button)); login_layout_util::WrapViewForPreferredSize(note_action_button));
const gfx::Size action_size = note_action_button->GetPreferredSize(); const gfx::Size action_size = note_action_button->GetPreferredSize();
EXPECT_EQ(gfx::Size(kLargeButtonRadiusDp, kLargeButtonRadiusDp), action_size); EXPECT_EQ(gfx::Size(kLargeButtonRadiusDp, kLargeButtonRadiusDp), action_size);
...@@ -327,7 +327,7 @@ TEST_F(NoteActionLaunchButtonTest, MultiFingerFling) { ...@@ -327,7 +327,7 @@ TEST_F(NoteActionLaunchButtonTest, MultiFingerFling) {
auto* note_action_button = auto* note_action_button =
new NoteActionLaunchButton(mojom::TrayActionState::kAvailable); new NoteActionLaunchButton(mojom::TrayActionState::kAvailable);
std::unique_ptr<views::Widget> widget = CreateWidgetWithContent( std::unique_ptr<views::Widget> widget = CreateWidgetWithContent(
login_views_utils::WrapViewForPreferredSize(note_action_button)); login_layout_util::WrapViewForPreferredSize(note_action_button));
const gfx::Size action_size = note_action_button->GetPreferredSize(); const gfx::Size action_size = note_action_button->GetPreferredSize();
EXPECT_EQ(gfx::Size(kLargeButtonRadiusDp, kLargeButtonRadiusDp), action_size); EXPECT_EQ(gfx::Size(kLargeButtonRadiusDp, kLargeButtonRadiusDp), action_size);
......
...@@ -5,10 +5,10 @@ ...@@ -5,10 +5,10 @@
#include "ash/login/ui/scrollable_users_list_view.h" #include "ash/login/ui/scrollable_users_list_view.h"
#include "ash/login/ui/hover_notifier.h" #include "ash/login/ui/hover_notifier.h"
#include "ash/login/ui/layout_util.h"
#include "ash/login/ui/login_display_style.h" #include "ash/login/ui/login_display_style.h"
#include "ash/login/ui/login_user_view.h" #include "ash/login/ui/login_user_view.h"
#include "ash/login/ui/non_accessible_view.h" #include "ash/login/ui/non_accessible_view.h"
#include "ash/login/ui/views_utils.h"
#include "ash/public/cpp/login_constants.h" #include "ash/public/cpp/login_constants.h"
#include "ash/public/interfaces/login_user_info.mojom.h" #include "ash/public/interfaces/login_user_info.mojom.h"
#include "ash/shell.h" #include "ash/shell.h"
...@@ -278,7 +278,7 @@ void ScrollableUsersListView::Layout() { ...@@ -278,7 +278,7 @@ void ScrollableUsersListView::Layout() {
// Update |contents()| layout spec. // Update |contents()| layout spec.
bool should_show_landscape = bool should_show_landscape =
login_views_utils::ShouldShowLandscape(GetWidget()); login_layout_util::ShouldShowLandscape(GetWidget());
LayoutParams layout_params = BuildLayoutForStyle(display_style_); LayoutParams layout_params = BuildLayoutForStyle(display_style_);
contents_layout_->set_inside_border_insets( contents_layout_->set_inside_border_insets(
should_show_landscape ? layout_params.insets_landscape should_show_landscape ? layout_params.insets_landscape
......
...@@ -128,6 +128,7 @@ TEST_F(LoginMetricsRecorderTest, UnlockAttempts) { ...@@ -128,6 +128,7 @@ TEST_F(LoginMetricsRecorderTest, UnlockAttempts) {
auth_method); auth_method);
EXPECT_CALL(*client, EXPECT_CALL(*client,
AuthenticateUser_(primary_user, testing::_, false, testing::_)); AuthenticateUser_(primary_user, testing::_, false, testing::_));
EXPECT_CALL(*client, OnFocusPod(primary_user));
// Authentication attempt with password "abc1"; // Authentication attempt with password "abc1";
ui::test::EventGenerator* generator = GetEventGenerator(); ui::test::EventGenerator* generator = GetEventGenerator();
......
...@@ -12,7 +12,6 @@ ...@@ -12,7 +12,6 @@
#include "ash/lock_screen_action/test_lock_screen_action_background_controller.h" #include "ash/lock_screen_action/test_lock_screen_action_background_controller.h"
#include "ash/login/mock_login_screen_client.h" #include "ash/login/mock_login_screen_client.h"
#include "ash/login/ui/login_test_base.h" #include "ash/login/ui/login_test_base.h"
#include "ash/login/ui/views_utils.h"
#include "ash/public/interfaces/kiosk_app_info.mojom.h" #include "ash/public/interfaces/kiosk_app_info.mojom.h"
#include "ash/root_window_controller.h" #include "ash/root_window_controller.h"
#include "ash/session/session_controller.h" #include "ash/session/session_controller.h"
...@@ -38,14 +37,25 @@ using session_manager::SessionState; ...@@ -38,14 +37,25 @@ using session_manager::SessionState;
namespace ash { namespace ash {
namespace { namespace {
// Returns true if |view| or any child of it has focus.
bool HasFocusInAnyChildView(views::View* view) {
if (view->HasFocus())
return true;
for (int i = 0; i < view->child_count(); ++i) {
if (HasFocusInAnyChildView(view->child_at(i)))
return true;
}
return false;
}
void ExpectFocused(views::View* view) { void ExpectFocused(views::View* view) {
EXPECT_TRUE(view->GetWidget()->IsActive()); EXPECT_TRUE(view->GetWidget()->IsActive());
EXPECT_TRUE(login_views_utils::HasFocusInAnyChildView(view)); EXPECT_TRUE(HasFocusInAnyChildView(view));
} }
void ExpectNotFocused(views::View* view) { void ExpectNotFocused(views::View* view) {
EXPECT_FALSE(view->GetWidget()->IsActive()); EXPECT_FALSE(view->GetWidget()->IsActive());
EXPECT_FALSE(login_views_utils::HasFocusInAnyChildView(view)); EXPECT_FALSE(HasFocusInAnyChildView(view));
} }
class LoginShelfViewTest : public LoginTestBase { class LoginShelfViewTest : public LoginTestBase {
......
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