Commit cbc1ee0f authored by Jacob Dufault's avatar Jacob Dufault Committed by Commit Bot

cros: Add test to lock to ensure password field is read only after submit

Bug: 808486
Change-Id: Icb5491be8b04afa9935147f64c43a08877e34a73
Reviewed-on: https://chromium-review.googlesource.com/900306Reviewed-by: default avatarXiyuan Xia <xiyuan@chromium.org>
Reviewed-by: default avatarJames Cook <jamescook@chromium.org>
Commit-Queue: Jacob Dufault <jdufault@chromium.org>
Cr-Commit-Position: refs/heads/master@{#539901}
parent a3c8a81f
......@@ -87,9 +87,9 @@ void LoginScreenController::SetClient(mojom::LoginScreenClientPtr client) {
}
void LoginScreenController::ShowLockScreen(ShowLockScreenCallback on_shown) {
OnShow();
ash::LockScreen::Show(ash::LockScreen::ScreenType::kLock);
std::move(on_shown).Run(true);
SetSystemTrayVisibility(SystemTrayVisibility::kPrimary);
}
void LoginScreenController::ShowLoginScreen(ShowLoginScreenCallback on_shown) {
......@@ -100,10 +100,10 @@ void LoginScreenController::ShowLoginScreen(ShowLoginScreenCallback on_shown) {
return;
}
OnShow();
// TODO(jdufault): rename ash::LockScreen to ash::LoginScreen.
ash::LockScreen::Show(ash::LockScreen::ScreenType::kLogin);
std::move(on_shown).Run(true);
SetSystemTrayVisibility(SystemTrayVisibility::kPrimary);
}
void LoginScreenController::ShowErrorMessage(int32_t login_attempts,
......@@ -368,4 +368,9 @@ LoginDataDispatcher* LoginScreenController::DataDispatcher() const {
return ash::LockScreen::Get()->data_dispatcher();
}
void LoginScreenController::OnShow() {
SetSystemTrayVisibility(SystemTrayVisibility::kPrimary);
is_authenticating_ = false;
}
} // namespace ash
......@@ -120,6 +120,9 @@ class ASH_EXPORT LoginScreenController : public mojom::LoginScreen {
// Returns the active data dispatcher or nullptr if there is no lock screen.
LoginDataDispatcher* DataDispatcher() const;
// Common code that is called when the login/lock screen is shown.
void OnShow();
// Client interface in chrome browser. May be null in tests.
mojom::LoginScreenClientPtr login_screen_client_;
......
......@@ -172,17 +172,21 @@ TEST_F(LockScreenSanityTest,
// cleared after the ash callback handler has completed and auth has failed.
submit_password();
EXPECT_FALSE(password_test_api.textfield()->text().empty());
EXPECT_TRUE(password_test_api.textfield()->read_only());
std::move(callback).Run(false);
base::RunLoop().RunUntilIdle();
EXPECT_TRUE(password_test_api.textfield()->text().empty());
EXPECT_FALSE(password_test_api.textfield()->read_only());
// Repeat the above process. Verify that the password is not cleared if auth
// succeeds.
submit_password();
EXPECT_FALSE(password_test_api.textfield()->text().empty());
EXPECT_TRUE(password_test_api.textfield()->read_only());
std::move(callback).Run(true);
base::RunLoop().RunUntilIdle();
EXPECT_FALSE(password_test_api.textfield()->text().empty());
EXPECT_TRUE(password_test_api.textfield()->read_only());
}
// Verifies that tabbing from the lock screen will eventually focus the shelf.
......
......@@ -61,6 +61,9 @@ void LoginScreenClient::AuthenticateUser(
delegate_->HandleAuthenticateUser(account_id, hashed_password,
sync_password_data, authenticated_by_pin,
std::move(callback));
} else {
LOG(ERROR) << "Returning failed authentication attempt; no delegate";
std::move(callback).Run(false);
}
}
......
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