Commit 786f10ee authored by Aya Elgendy's avatar Aya Elgendy Committed by Commit Bot

Support Latin letters in the smart card pin dialog

Add UI support for alphanumeric pins used on user login via
smart cards.

Previously, Latin letters were consciously ignored.
Also added a unit test for non-digit pin inputs.

Bug: 1144194

Change-Id: I556f1fd8a07fa1a8a1d76130ee116c3a0e86e2b7
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2518976Reviewed-by: default avatarFabian Sommer <fabiansommer@chromium.org>
Reviewed-by: default avatarDenis Kuznetsov [CET] <antrim@chromium.org>
Reviewed-by: default avatarMaksim Ivanov <emaxx@chromium.org>
Commit-Queue: Aya Nader Elgendy‎ <ayag@chromium.org>
Cr-Commit-Position: refs/heads/master@{#826492}
parent c39b58aa
......@@ -161,10 +161,6 @@ bool FlexCodeInput::HandleKeyEvent(views::Textfield* sender,
return true;
}
// We only expect digits in the PIN, so we swallow all letters.
if (key_code >= ui::VKEY_A && key_code <= ui::VKEY_Z)
return true;
return false;
}
......
......@@ -55,11 +55,11 @@ class FlexCodeInput : public AccessCodeInput {
using OnEscape = base::RepeatingClosure;
// Builds the view for an access code that consists out of an unknown number
// of digits. |on_input_change| will be called upon digit insertion, deletion
// or change. |on_enter| will be called when code is complete and user presses
// enter to submit it for validation. |on_escape| will be called when pressing
// the escape key. |obscure_pin| determines whether the entered pin is
// displayed as clear text or as bullet points.
// of characters. |on_input_change| will be called upon character insertion,
// deletion or change. |on_enter| will be called when code is complete and
// user presses enter to submit it for validation. |on_escape| will be called
// when pressing the escape key. |obscure_pin| determines whether the entered
// pin is displayed as clear text or as bullet points.
FlexCodeInput(OnInputChange on_input_change,
OnEnter on_enter,
OnEscape on_escape,
......@@ -104,8 +104,8 @@ class FlexCodeInput : public AccessCodeInput {
private:
views::Textfield* code_field_;
// To be called when access input code changes (digit is inserted, deleted or
// updated). Passes true when code non-empty.
// To be called when access input code changes (character is inserted, deleted
// or updated). Passes true when code non-empty.
OnInputChange on_input_change_;
// To be called when user pressed enter to submit.
......
......@@ -356,7 +356,7 @@ TEST_F(PinRequestViewTest, Backspace) {
EXPECT_EQ("012323", last_code_submitted_);
}
// Tests input with unknown pin length.
// Tests digit-only input with unknown pin length.
TEST_F(PinRequestViewTest, FlexCodeInput) {
StartView(base::nullopt);
PinRequestView::TestApi test_api(view_);
......@@ -381,6 +381,36 @@ TEST_F(PinRequestViewTest, FlexCodeInput) {
EXPECT_EQ("0123456", last_code_submitted_);
}
// Tests non-digit input with unknown pin length.
TEST_F(PinRequestViewTest, FlexCodeInputCharacters) {
StartView(base::nullopt);
PinRequestView::TestApi test_api(view_);
ui::test::EventGenerator* generator = GetEventGenerator();
will_authenticate_ = false;
EXPECT_FALSE(test_api.submit_button()->GetEnabled());
for (int i = 0; i < 3; ++i) {
generator->PressKey(ui::KeyboardCode(ui::KeyboardCode::VKEY_A + i),
ui::EF_NONE);
base::RunLoop().RunUntilIdle();
}
for (int i = 0; i < 3; ++i) {
generator->PressKey(ui::KeyboardCode(ui::KeyboardCode::VKEY_A + i),
ui::EF_SHIFT_DOWN);
base::RunLoop().RunUntilIdle();
}
generator->PressKey(ui::KeyboardCode(ui::KeyboardCode::VKEY_ADD),
ui::EF_NONE);
generator->PressKey(ui::KeyboardCode(ui::KeyboardCode::VKEY_SUBTRACT),
ui::EF_NONE);
EXPECT_TRUE(test_api.submit_button()->GetEnabled());
SimulateMouseClickAt(GetEventGenerator(), test_api.submit_button());
EXPECT_EQ(1, pin_submitted_);
EXPECT_EQ("abcABC+-", last_code_submitted_);
}
// Tests input with virtual pin keyboard.
TEST_F(PinRequestViewTest, PinKeyboard) {
ShowWidget();
......
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