Commit 68a6654d authored by Aga Wronska's avatar Aga Wronska Committed by Commit Bot

Make sure users list on login screen resizes properly after virtual keyboard is dismissed.

Add tests for layout of users list after rotation and after
virtual keyboard apperance changes.

Extract LoginKeyboardTestBase class as a base for tests that
need to manipulate virtual keyboard.

Bug: 807827
Change-Id: I46a300ebbce8a59c9648573fede203ca0f21a292
Reviewed-on: https://chromium-review.googlesource.com/896966
Commit-Queue: Aga Wronska <agawronska@chromium.org>
Reviewed-by: default avatarJacob Dufault <jdufault@chromium.org>
Cr-Commit-Position: refs/heads/master@{#534115}
parent c818c4ae
...@@ -1391,6 +1391,8 @@ test("ash_unittests") { ...@@ -1391,6 +1391,8 @@ test("ash_unittests") {
"login/ui/lock_window_unittest.cc", "login/ui/lock_window_unittest.cc",
"login/ui/login_auth_user_view_unittest.cc", "login/ui/login_auth_user_view_unittest.cc",
"login/ui/login_bubble_unittest.cc", "login/ui/login_bubble_unittest.cc",
"login/ui/login_keyboard_test_base.cc",
"login/ui/login_keyboard_test_base.h",
"login/ui/login_password_view_test.cc", "login/ui/login_password_view_test.cc",
"login/ui/login_pin_view_unittest.cc", "login/ui/login_pin_view_unittest.cc",
"login/ui/login_test_base.cc", "login/ui/login_test_base.cc",
......
...@@ -6,14 +6,15 @@ ...@@ -6,14 +6,15 @@
#include <unordered_set> #include <unordered_set>
#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/login_auth_user_view.h" #include "ash/login/ui/login_auth_user_view.h"
#include "ash/login/ui/login_bubble.h" #include "ash/login/ui/login_bubble.h"
#include "ash/login/ui/login_display_style.h" #include "ash/login/ui/login_display_style.h"
#include "ash/login/ui/login_keyboard_test_base.h"
#include "ash/login/ui/login_test_base.h" #include "ash/login/ui/login_test_base.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/public/interfaces/tray_action.mojom.h" #include "ash/public/interfaces/tray_action.mojom.h"
#include "ash/shell.h"
#include "base/strings/utf_string_conversions.h" #include "base/strings/utf_string_conversions.h"
#include "testing/gtest/include/gtest/gtest.h" #include "testing/gtest/include/gtest/gtest.h"
#include "ui/display/manager/display_manager.h" #include "ui/display/manager/display_manager.h"
...@@ -25,6 +26,7 @@ ...@@ -25,6 +26,7 @@
namespace ash { namespace ash {
using LockContentsViewUnitTest = LoginTestBase; using LockContentsViewUnitTest = LoginTestBase;
using LockContentsViewKeyboardUnitTest = LoginKeyboardTestBase;
TEST_F(LockContentsViewUnitTest, DisplayMode) { TEST_F(LockContentsViewUnitTest, DisplayMode) {
// Build lock screen with 1 user. // Build lock screen with 1 user.
...@@ -164,6 +166,153 @@ TEST_F(LockContentsViewUnitTest, AutoLayoutAfterRotation) { ...@@ -164,6 +166,153 @@ TEST_F(LockContentsViewUnitTest, AutoLayoutAfterRotation) {
} }
} }
TEST_F(LockContentsViewUnitTest, AutoLayoutExtraSmallUsersListAfterRotation) {
// Build lock screen with extra small layout (> 6 users).
auto* contents = new LockContentsView(mojom::TrayActionState::kNotAvailable,
data_dispatcher());
SetUserCount(9);
ScrollableUsersListView* users_list =
LockContentsView::TestApi(contents).users_list();
std::unique_ptr<views::Widget> widget = CreateWidgetWithContent(contents);
// Users list in extra small layout should adjust its height to parent.
EXPECT_EQ(contents->height(), users_list->height());
const display::Display& display =
display::Screen::GetScreen()->GetDisplayNearestWindow(
widget->GetNativeWindow());
// Start at 0 degrees (landscape).
display_manager()->SetDisplayRotation(
display.id(), display::Display::ROTATE_0,
display::Display::ROTATION_SOURCE_ACTIVE);
EXPECT_EQ(contents->height(), users_list->height());
// Rotate the display to 90 degrees (portrait).
display_manager()->SetDisplayRotation(
display.id(), display::Display::ROTATE_90,
display::Display::ROTATION_SOURCE_ACTIVE);
EXPECT_EQ(contents->height(), users_list->height());
// Rotate the display back to 0 degrees (landscape).
display_manager()->SetDisplayRotation(
display.id(), display::Display::ROTATE_0,
display::Display::ROTATION_SOURCE_ACTIVE);
EXPECT_EQ(contents->height(), users_list->height());
}
TEST_F(LockContentsViewUnitTest, AutoLayoutSmallUsersListAfterRotation) {
// Build lock screen with small layout (3-6 users).
auto* contents = new LockContentsView(mojom::TrayActionState::kNotAvailable,
data_dispatcher());
SetUserCount(4);
ScrollableUsersListView* users_list =
LockContentsView::TestApi(contents).users_list();
std::unique_ptr<views::Widget> widget = CreateWidgetWithContent(contents);
// Calculate top spacing between users list and lock screen contents.
auto top_margin = [&]() {
return users_list->GetBoundsInScreen().y() -
contents->GetBoundsInScreen().y();
};
// Calculate bottom spacing between users list and lock screen contents.
auto bottom_margin = [&]() {
return contents->GetBoundsInScreen().bottom() -
users_list->GetBoundsInScreen().bottom();
};
// Users list in small layout should adjust its height to content and be
// vertical centered in parent.
EXPECT_EQ(top_margin(), bottom_margin());
EXPECT_EQ(users_list->height(), users_list->contents()->height());
const display::Display& display =
display::Screen::GetScreen()->GetDisplayNearestWindow(
widget->GetNativeWindow());
// Start at 0 degrees (landscape).
display_manager()->SetDisplayRotation(
display.id(), display::Display::ROTATE_0,
display::Display::ROTATION_SOURCE_ACTIVE);
EXPECT_EQ(top_margin(), bottom_margin());
EXPECT_EQ(users_list->height(), users_list->contents()->height());
// Rotate the display to 90 degrees (portrait).
display_manager()->SetDisplayRotation(
display.id(), display::Display::ROTATE_90,
display::Display::ROTATION_SOURCE_ACTIVE);
EXPECT_EQ(top_margin(), bottom_margin());
EXPECT_EQ(users_list->height(), users_list->contents()->height());
// Rotate the display back to 0 degrees (landscape).
display_manager()->SetDisplayRotation(
display.id(), display::Display::ROTATE_0,
display::Display::ROTATION_SOURCE_ACTIVE);
EXPECT_EQ(top_margin(), bottom_margin());
EXPECT_EQ(users_list->height(), users_list->contents()->height());
}
TEST_F(LockContentsViewKeyboardUnitTest,
AutoLayoutExtraSmallUsersListForKeyboard) {
// Build lock screen with extra small layout (> 6 users).
ASSERT_NO_FATAL_FAILURE(ShowLoginScreen());
LockContentsView* contents =
LockScreen::TestApi(LockScreen::Get()).contents_view();
ASSERT_NE(nullptr, contents);
LoadUsers(9);
// Users list in extra small layout should adjust its height to parent.
ScrollableUsersListView* users_list =
LockContentsView::TestApi(contents).users_list();
EXPECT_EQ(contents->height(), users_list->height());
ASSERT_NO_FATAL_FAILURE(ShowKeyboard());
gfx::Rect keyboard_bounds = GetKeyboardBoundsInScreen();
EXPECT_FALSE(users_list->GetBoundsInScreen().Intersects(keyboard_bounds));
EXPECT_EQ(contents->height(), users_list->height());
ASSERT_NO_FATAL_FAILURE(HideKeyboard());
EXPECT_EQ(contents->height(), users_list->height());
}
TEST_F(LockContentsViewKeyboardUnitTest, AutoLayoutSmallUsersListForKeyboard) {
// Build lock screen with small layout (3-6 users).
ASSERT_NO_FATAL_FAILURE(ShowLoginScreen());
LockContentsView* contents =
LockScreen::TestApi(LockScreen::Get()).contents_view();
ASSERT_NE(nullptr, contents);
LoadUsers(4);
ScrollableUsersListView* users_list =
LockContentsView::TestApi(contents).users_list();
// Calculate top spacing between users list and lock screen contents.
auto top_margin = [&]() {
return users_list->GetBoundsInScreen().y() -
contents->GetBoundsInScreen().y();
};
// Calculate bottom spacing between users list and lock screen contents.
auto bottom_margin = [&]() {
return contents->GetBoundsInScreen().bottom() -
users_list->GetBoundsInScreen().bottom();
};
// Users list in small layout should adjust its height to content and be
// vertical centered in parent.
EXPECT_EQ(top_margin(), bottom_margin());
EXPECT_EQ(users_list->height(), users_list->contents()->height());
ASSERT_NO_FATAL_FAILURE(ShowKeyboard());
gfx::Rect keyboard_bounds = GetKeyboardBoundsInScreen();
EXPECT_FALSE(users_list->GetBoundsInScreen().Intersects(keyboard_bounds));
EXPECT_EQ(top_margin(), bottom_margin());
ASSERT_NO_FATAL_FAILURE(HideKeyboard());
EXPECT_EQ(top_margin(), bottom_margin());
EXPECT_EQ(users_list->height(), users_list->contents()->height());
}
// Ensures that when swapping between two users, only auth method display swaps. // Ensures that when swapping between two users, only auth method display swaps.
TEST_F(LockContentsViewUnitTest, SwapAuthUsersInTwoUserLayout) { TEST_F(LockContentsViewUnitTest, SwapAuthUsersInTwoUserLayout) {
// Build lock screen with two users. // Build lock screen with two users.
......
...@@ -4,88 +4,14 @@ ...@@ -4,88 +4,14 @@
#include "ash/login/ui/lock_window.h" #include "ash/login/ui/lock_window.h"
#include "ash/login/login_screen_controller.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_test_base.h" #include "ash/login/ui/login_keyboard_test_base.h"
#include "ash/login/ui/login_test_utils.h" #include "ash/login/ui/login_test_utils.h"
#include "ash/public/interfaces/login_user_info.mojom.h"
#include "ash/root_window_controller.h"
#include "ash/session/session_controller.h"
#include "ash/session/test_session_controller_client.h"
#include "ash/shell.h"
#include "base/command_line.h"
#include "base/run_loop.h"
#include "ui/keyboard/keyboard_controller.h"
#include "ui/keyboard/keyboard_switches.h"
#include "ui/keyboard/keyboard_test_util.h"
#include "ui/keyboard/keyboard_ui.h"
#include "ui/keyboard/keyboard_util.h"
namespace ash { namespace ash {
class LockWindowVirtualKeyboardTest : public LoginTestBase { using LockWindowVirtualKeyboardTest = LoginKeyboardTestBase;
public:
LockWindowVirtualKeyboardTest() = default;
~LockWindowVirtualKeyboardTest() override = default;
void SetUp() override {
base::CommandLine::ForCurrentProcess()->AppendSwitch(
keyboard::switches::kEnableVirtualKeyboard);
AshTestBase::SetUp();
GetSessionControllerClient()->SetSessionState(
session_manager::SessionState::LOCKED);
login_controller_ = Shell::Get()->login_screen_controller();
ASSERT_NE(nullptr, login_controller_);
}
void TearDown() override {
if (ash::LockScreen::IsShown())
ash::LockScreen::Get()->Destroy();
AshTestBase::TearDown();
}
void ShowLockScreen() {
base::Optional<bool> result;
login_controller_->ShowLockScreen(base::BindOnce(
[](base::Optional<bool>* result, bool did_show) { *result = did_show; },
&result));
base::RunLoop().RunUntilIdle();
ASSERT_TRUE(result.has_value());
ASSERT_EQ(*result, true);
}
void LoadUser() {
std::vector<mojom::LoginUserInfoPtr> users;
users.push_back(CreateUser("user1"));
login_controller_->LoadUsers(std::move(users), false);
}
void ShowKeyboard() {
keyboard::KeyboardController* controller =
keyboard::KeyboardController::GetInstance();
ASSERT_NE(nullptr, controller);
Shell::GetPrimaryRootWindowController()->ActivateKeyboard(controller);
controller->ShowKeyboard(false);
// Set keyboard height to half of the root window - this should overlap with
// lock/login layout.
if (controller->ui()->GetContentsWindow()->bounds().height() == 0) {
int height = Shell::GetPrimaryRootWindow()->bounds().height() / 2;
controller->ui()->GetContentsWindow()->SetBounds(
keyboard::KeyboardBoundsFromRootBounds(
Shell::GetPrimaryRootWindow()->bounds(), height));
}
ASSERT_TRUE(controller->keyboard_visible());
}
LoginScreenController* login_controller_;
private:
DISALLOW_COPY_AND_ASSIGN(LockWindowVirtualKeyboardTest);
};
TEST_F(LockWindowVirtualKeyboardTest, VirtualKeyboardDoesNotCoverAuthView) { TEST_F(LockWindowVirtualKeyboardTest, VirtualKeyboardDoesNotCoverAuthView) {
ASSERT_NO_FATAL_FAILURE(ShowLockScreen()); ASSERT_NO_FATAL_FAILURE(ShowLockScreen());
...@@ -93,19 +19,15 @@ TEST_F(LockWindowVirtualKeyboardTest, VirtualKeyboardDoesNotCoverAuthView) { ...@@ -93,19 +19,15 @@ TEST_F(LockWindowVirtualKeyboardTest, VirtualKeyboardDoesNotCoverAuthView) {
LockScreen::TestApi(LockScreen::Get()).contents_view(); LockScreen::TestApi(LockScreen::Get()).contents_view();
ASSERT_NE(nullptr, lock_contents); ASSERT_NE(nullptr, lock_contents);
LoadUser(); LoadUsers(1);
LoginAuthUserView* auth_view = LoginAuthUserView* auth_view =
MakeLockContentsViewTestApi(lock_contents).primary_auth(); MakeLockContentsViewTestApi(lock_contents).primary_auth();
ASSERT_NE(nullptr, auth_view); ASSERT_NE(nullptr, auth_view);
ASSERT_NO_FATAL_FAILURE(ShowKeyboard()); ASSERT_NO_FATAL_FAILURE(ShowKeyboard());
const gfx::Rect keyboard_bounds_in_screen =
keyboard::KeyboardController::GetInstance()
->ui()
->GetContentsWindow()
->GetBoundsInScreen();
EXPECT_FALSE( EXPECT_FALSE(
auth_view->GetBoundsInScreen().Intersects(keyboard_bounds_in_screen)); auth_view->GetBoundsInScreen().Intersects(GetKeyboardBoundsInScreen()));
} }
} // namespace ash } // namespace ash
...@@ -4,6 +4,7 @@ ...@@ -4,6 +4,7 @@
#include "ash/login/ui/login_auth_user_view.h" #include "ash/login/ui/login_auth_user_view.h"
#include "ash/login/ui/login_test_base.h" #include "ash/login/ui/login_test_base.h"
#include "ash/login/ui/login_test_utils.h"
#include "testing/gtest/include/gtest/gtest.h" #include "testing/gtest/include/gtest/gtest.h"
#include "ui/views/layout/box_layout.h" #include "ui/views/layout/box_layout.h"
#include "ui/views/widget/widget.h" #include "ui/views/widget/widget.h"
......
// Copyright 2018 The Chromium Authors. All rights reserved.
// 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_keyboard_test_base.h"
#include "ash/login/login_screen_controller.h"
#include "ash/login/ui/lock_screen.h"
#include "ash/login/ui/login_test_utils.h"
#include "ash/root_window_controller.h"
#include "ash/session/test_session_controller_client.h"
#include "ash/shell.h"
#include "base/command_line.h"
#include "ui/keyboard/keyboard_controller.h"
#include "ui/keyboard/keyboard_switches.h"
#include "ui/keyboard/keyboard_test_util.h"
#include "ui/keyboard/keyboard_ui.h"
namespace ash {
LoginKeyboardTestBase::LoginKeyboardTestBase() = default;
LoginKeyboardTestBase::~LoginKeyboardTestBase() = default;
void LoginKeyboardTestBase::SetUp() {
base::CommandLine::ForCurrentProcess()->AppendSwitch(
keyboard::switches::kEnableVirtualKeyboard);
AshTestBase::SetUp();
login_controller_ = Shell::Get()->login_screen_controller();
ASSERT_NE(nullptr, login_controller_);
keyboard_controller_ = keyboard::KeyboardController::GetInstance();
ASSERT_NE(nullptr, keyboard_controller_);
Shell::GetPrimaryRootWindowController()->ActivateKeyboard(
keyboard_controller_);
}
void LoginKeyboardTestBase::TearDown() {
Shell::GetPrimaryRootWindowController()->DeactivateKeyboard(
keyboard_controller_);
if (ash::LockScreen::IsShown())
ash::LockScreen::Get()->Destroy();
AshTestBase::TearDown();
}
void LoginKeyboardTestBase::ShowKeyboard() {
keyboard_controller_->ShowKeyboard(false);
// Set keyboard height to half of the root window - this should overlap with
// lock/login layout.
if (keyboard_controller_->ui()->GetContentsWindow()->bounds().height() == 0) {
int height = Shell::GetPrimaryRootWindow()->bounds().height() / 2;
keyboard_controller_->ui()->GetContentsWindow()->SetBounds(
keyboard::KeyboardBoundsFromRootBounds(
Shell::GetPrimaryRootWindow()->bounds(), height));
}
ASSERT_TRUE(keyboard_controller_->keyboard_visible());
}
void LoginKeyboardTestBase::HideKeyboard() {
keyboard_controller_->HideKeyboard(
keyboard::KeyboardController::HIDE_REASON_MANUAL);
ASSERT_FALSE(keyboard_controller_->keyboard_visible());
}
gfx::Rect LoginKeyboardTestBase::GetKeyboardBoundsInScreen() const {
return keyboard_controller_->ui()->GetContentsWindow()->GetBoundsInScreen();
}
void LoginKeyboardTestBase::ShowLockScreen() {
GetSessionControllerClient()->SetSessionState(
session_manager::SessionState::LOCKED);
base::Optional<bool> result;
login_controller_->ShowLockScreen(base::BindOnce(
[](base::Optional<bool>* result, bool did_show) { *result = did_show; },
&result));
base::RunLoop().RunUntilIdle();
ASSERT_TRUE(result.has_value());
ASSERT_EQ(*result, true);
}
void LoginKeyboardTestBase::ShowLoginScreen() {
GetSessionControllerClient()->SetSessionState(
session_manager::SessionState::LOGIN_PRIMARY);
base::Optional<bool> result;
login_controller_->ShowLoginScreen(base::BindOnce(
[](base::Optional<bool>* result, bool did_show) { *result = did_show; },
&result));
base::RunLoop().RunUntilIdle();
ASSERT_TRUE(result.has_value());
ASSERT_EQ(*result, true);
}
void LoginKeyboardTestBase::LoadUsers(int count) {
std::vector<mojom::LoginUserInfoPtr> users;
for (int i = 0; i < count; ++i) {
users.push_back(CreateUser("user"));
}
login_controller_->LoadUsers(std::move(users), false);
}
} // namespace ash
// Copyright 2018 The Chromium Authors. All rights reserved.
// 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_KEYBOARD_TEST_BASE_H_
#define ASH_LOGIN_UI_LOGIN_KEYBOARD_TEST_BASE_H_
#include <memory>
#include "ash/test/ash_test_base.h"
namespace keyboard {
class KeyboardController;
} // namespace keyboard
namespace ash {
class LoginScreenController;
// Base test fixture for testing the views-based login and lock screens with
// virtual keyboard.
class LoginKeyboardTestBase : public AshTestBase {
public:
LoginKeyboardTestBase();
~LoginKeyboardTestBase() override;
// Shows keyboard with the height of half of the window height. Asserts that
// keyboard is visible. To stop execution of the test on failed assertion
// use ASSERT_NO_FATAL_FAILURE macro.
void ShowKeyboard();
// Hides keyboard. Asserts that keyboard is not visible. To stop execution of
// the test on failed assertion use ASSERT_NO_FATAL_FAILURE macro.
void HideKeyboard();
// Returns bounds of the keyboard in screen coordinate space.
gfx::Rect GetKeyboardBoundsInScreen() const;
// Shows lock screen. Asserts that lock screen is shown. To stop execution of
// the test on failed assertion use ASSERT_NO_FATAL_FAILURE macro.
void ShowLockScreen();
// Shows login screen. Asserts that login screen is shown. To stop execution
// of the test on failed assertion use ASSERT_NO_FATAL_FAILURE macro.
void ShowLoginScreen();
// Loads the number of test users specified by |count|;
void LoadUsers(int count);
// AshTestBase:
void SetUp() override;
void TearDown() override;
private:
keyboard::KeyboardController* keyboard_controller_ = nullptr;
LoginScreenController* login_controller_ = nullptr;
DISALLOW_COPY_AND_ASSIGN(LoginKeyboardTestBase);
};
} // namespace ash
#endif // ASH_LOGIN_UI_LOGIN_KEYBOARD_TEST_BASE_H_
...@@ -6,6 +6,7 @@ ...@@ -6,6 +6,7 @@
#include <string> #include <string>
#include "ash/login/ui/login_test_utils.h"
#include "ash/public/cpp/config.h" #include "ash/public/cpp/config.h"
#include "ash/public/cpp/shell_window_ids.h" #include "ash/public/cpp/shell_window_ids.h"
#include "ash/public/interfaces/tray_action.mojom.h" #include "ash/public/interfaces/tray_action.mojom.h"
...@@ -68,18 +69,6 @@ std::unique_ptr<views::Widget> LoginTestBase::CreateWidgetWithContent( ...@@ -68,18 +69,6 @@ std::unique_ptr<views::Widget> LoginTestBase::CreateWidgetWithContent(
return new_widget; return new_widget;
} }
mojom::LoginUserInfoPtr LoginTestBase::CreateUser(
const std::string& name) const {
auto user = mojom::LoginUserInfo::New();
user->basic_user_info = mojom::UserInfo::New();
user->basic_user_info->account_id =
AccountId::FromUserEmail(name + "@foo.com");
user->basic_user_info->display_name = "User " + name;
user->basic_user_info->display_email =
user->basic_user_info->account_id.GetUserEmail();
return user;
}
void LoginTestBase::SetUserCount(size_t count) { void LoginTestBase::SetUserCount(size_t count) {
// Add missing users, then remove extra users. // Add missing users, then remove extra users.
while (users_.size() < count) while (users_.size() < count)
......
...@@ -37,9 +37,6 @@ class LoginTestBase : public AshTestBase { ...@@ -37,9 +37,6 @@ class LoginTestBase : public AshTestBase {
// shown. // shown.
std::unique_ptr<views::Widget> CreateWidgetWithContent(views::View* content); std::unique_ptr<views::Widget> CreateWidgetWithContent(views::View* content);
// Utility method to create a new |mojom::UserInfoPtr| instance.
mojom::LoginUserInfoPtr CreateUser(const std::string& name) const;
// Changes the active number of users. Fires an event on |data_dispatcher()|. // Changes the active number of users. Fires an event on |data_dispatcher()|.
void SetUserCount(size_t count); void SetUserCount(size_t count);
......
...@@ -20,4 +20,15 @@ LoginPasswordView::TestApi MakeLoginPasswordTestApi(LockContentsView* view) { ...@@ -20,4 +20,15 @@ LoginPasswordView::TestApi MakeLoginPasswordTestApi(LockContentsView* view) {
MakeLoginPrimaryAuthTestApi(view).password_view()); MakeLoginPrimaryAuthTestApi(view).password_view());
} }
mojom::LoginUserInfoPtr CreateUser(const std::string& name) {
auto user = mojom::LoginUserInfo::New();
user->basic_user_info = mojom::UserInfo::New();
user->basic_user_info->account_id =
AccountId::FromUserEmail(name + "@foo.com");
user->basic_user_info->display_name = "User " + name;
user->basic_user_info->display_email =
user->basic_user_info->account_id.GetUserEmail();
return user;
}
} // namespace ash } // namespace ash
...@@ -8,6 +8,7 @@ ...@@ -8,6 +8,7 @@
#include "ash/login/ui/lock_contents_view.h" #include "ash/login/ui/lock_contents_view.h"
#include "ash/login/ui/login_auth_user_view.h" #include "ash/login/ui/login_auth_user_view.h"
#include "ash/login/ui/login_password_view.h" #include "ash/login/ui/login_password_view.h"
#include "ash/public/interfaces/login_user_info.mojom.h"
namespace ash { namespace ash {
...@@ -16,6 +17,9 @@ LockContentsView::TestApi MakeLockContentsViewTestApi(LockContentsView* view); ...@@ -16,6 +17,9 @@ LockContentsView::TestApi MakeLockContentsViewTestApi(LockContentsView* view);
LoginAuthUserView::TestApi MakeLoginPrimaryAuthTestApi(LockContentsView* view); LoginAuthUserView::TestApi MakeLoginPrimaryAuthTestApi(LockContentsView* view);
LoginPasswordView::TestApi MakeLoginPasswordTestApi(LockContentsView* view); LoginPasswordView::TestApi MakeLoginPasswordTestApi(LockContentsView* view);
// Utility method to create a new |mojom::UserInfoPtr| instance.
mojom::LoginUserInfoPtr CreateUser(const std::string& name);
} // namespace ash } // namespace ash
#endif // ASH_LOGIN_UI_LOGIN_TEST_UTILS_H_ #endif // ASH_LOGIN_UI_LOGIN_TEST_UTILS_H_
...@@ -5,6 +5,7 @@ ...@@ -5,6 +5,7 @@
#include "ash/login/ui/login_user_view.h" #include "ash/login/ui/login_user_view.h"
#include "ash/login/ui/login_display_style.h" #include "ash/login/ui/login_display_style.h"
#include "ash/login/ui/login_test_base.h" #include "ash/login/ui/login_test_base.h"
#include "ash/login/ui/login_test_utils.h"
#include "testing/gtest/include/gtest/gtest.h" #include "testing/gtest/include/gtest/gtest.h"
#include "ui/events/test/event_generator.h" #include "ui/events/test/event_generator.h"
#include "ui/gfx/geometry/rect.h" #include "ui/gfx/geometry/rect.h"
......
...@@ -177,10 +177,13 @@ void ScrollableUsersListView::Layout() { ...@@ -177,10 +177,13 @@ void ScrollableUsersListView::Layout() {
// Adjust height of the content. In extra small style, contents occupies the // Adjust height of the content. In extra small style, contents occupies the
// whole height of the parent. In small style, content is centered // whole height of the parent. In small style, content is centered
// vertically. // vertically.
ClipHeightTo(layout_params_.display_style == LoginDisplayStyle::kExtraSmall int target_height =
? parent_height layout_params_.display_style == LoginDisplayStyle::kExtraSmall
: contents_height, ? parent_height
parent_height); : contents_height;
ClipHeightTo(target_height, parent_height);
if (height() != target_height)
PreferredSizeChanged();
} }
ScrollView::Layout(); ScrollView::Layout();
if (scroll_bar_) if (scroll_bar_)
......
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