Commit 728911e3 authored by Aga Wronska's avatar Aga Wronska Committed by Commit Bot

child user: Add numpad support to parent access view

Bug: 934303
Test: ParentAccessViewTest
Change-Id: Ia073de5cd123a3babbd058d3326a02a95e582d57
Reviewed-on: https://chromium-review.googlesource.com/c/1481577Reviewed-by: default avatarMichael Giuffrida <michaelpg@chromium.org>
Reviewed-by: default avatarXiyuan Xia <xiyuan@chromium.org>
Commit-Queue: Aga Wronska <agawronska@chromium.org>
Cr-Commit-Position: refs/heads/master@{#634407}
parent 48f183ff
......@@ -172,6 +172,8 @@ class ParentAccessView::AccessCodeInput : public views::View,
// All key pressed events not handled below are ignored.
if (key_code >= ui::VKEY_0 && key_code <= ui::VKEY_9) {
InsertDigit(key_code - ui::VKEY_0);
} else if (key_code >= ui::VKEY_NUMPAD0 && key_code <= ui::VKEY_NUMPAD9) {
InsertDigit(key_code - ui::VKEY_NUMPAD0);
} else if (key_code == ui::VKEY_LEFT) {
FocusPreviousField();
} else if (key_code == ui::VKEY_RIGHT) {
......
......@@ -112,6 +112,21 @@ TEST_F(ParentAccessViewTest, SubmitButton) {
EXPECT_EQ(1, submit_action_);
}
// Tests that access code can be entered with numpad.
TEST_F(ParentAccessViewTest, Numpad) {
ParentAccessView::TestApi test_api(view_);
ui::test::EventGenerator* generator = GetEventGenerator();
for (int i = 0; i < 6; ++i)
generator->PressKey(ui::KeyboardCode(ui::VKEY_NUMPAD0 + i), ui::EF_NONE);
EXPECT_TRUE(test_api.submit_button()->enabled());
SimulateButtonPress(test_api.submit_button());
ASSERT_TRUE(code_.has_value());
EXPECT_EQ("012345", *code_);
EXPECT_EQ(1, submit_action_);
}
// Tests that backspace button works.
TEST_F(ParentAccessViewTest, Backspace) {
ParentAccessView::TestApi test_api(view_);
......
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