diff options
author | Vic Yang <victoryang@chromium.org> | 2012-06-21 17:23:32 +0800 |
---|---|---|
committer | Gerrit <chrome-bot@google.com> | 2012-06-25 08:39:13 -0700 |
commit | 1105a28a8cada9cf3338cf933dcfe4f82f8a784a (patch) | |
tree | 7ae7cc358ec4105ce43f1d39391bb6729a994c34 /test | |
parent | fb3e3283c4503f80fc73b4ef68d68e68c00bd1be (diff) | |
download | chrome-ec-1105a28a8cada9cf3338cf933dcfe4f82f8a784a.tar.gz |
Add a test of checking keyboard de-ghosting
This test check when a ghost key appears, it is correctly ignored.
BUG=chrome-os-partner:10285
TEST=Test passed.
Change-Id: Ic5a6a9b5c78a969899df7c7a82f1c9d0c01b1325
Reviewed-on: https://gerrit.chromium.org/gerrit/25831
Reviewed-by: Vincent Palatin <vpalatin@chromium.org>
Tested-by: Vic Yang <victoryang@chromium.org>
Commit-Ready: Vic Yang <victoryang@chromium.org>
Diffstat (limited to 'test')
-rw-r--r-- | test/build.mk | 6 | ||||
-rw-r--r-- | test/kb_deghost.py | 63 | ||||
-rw-r--r-- | test/kb_deghost.tasklist | 24 |
3 files changed, 92 insertions, 1 deletions
diff --git a/test/build.mk b/test/build.mk index e4ca8341c2..87a8a11d39 100644 --- a/test/build.mk +++ b/test/build.mk @@ -7,7 +7,7 @@ # test-list=hello pingpong timer_calib timer_dos timer_jump mutex thermal -test-list+=power_button +test-list+=power_button kb_deghost #disable: powerdemo pingpong-y=pingpong.o @@ -27,3 +27,7 @@ chip-mock-power_button-gpio.o=mock_gpio.o chip-mock-power_button-pwm.o=mock_pwm.o common-mock-power_button-x86_power.o=mock_x86_power.o common-mock-power_button-i8042.o=mock_i8042.o + +# Mock modules for 'kb_deghost' +chip-mock-kb_deghost-keyboard_scan_stub.o=mock_keyboard_scan_stub.o +common-mock-kb_deghost-i8042.o=mock_i8042.o diff --git a/test/kb_deghost.py b/test/kb_deghost.py new file mode 100644 index 0000000000..c9241e063e --- /dev/null +++ b/test/kb_deghost.py @@ -0,0 +1,63 @@ +# Copyright (c) 2011 The Chromium OS Authors. All rights reserved. +# Use of this source code is governed by a BSD-style license that can be +# found in the LICENSE file. +# +# Keyboard deghost test +# + +import time + +def check_no_output(helper, reg_ex): + success = False + try: + helper.wait_output(reg_ex, use_re=True, timeout=1) + except: + success = True + return success + +def test(helper): + # Wait for EC initialized + helper.wait_output("--- UART initialized") + + # Enable keyboard scanning and disable typematic + helper.ec_command("kbd enable") + helper.ec_command("typematic 1000000 1000000") + + # Press (1, 1) and (2, 2) + helper.ec_command("mockmatrix 1 1 1") + helper.wait_output("KB raw") + helper.ec_command("mockmatrix 2 2 1") + helper.wait_output("KB raw") + + # Now press (1, 2) which should cause (2, 1) to be pressed also + # Expect this is ignored + helper.ec_command("mockmatrix 2 1 1") + helper.ec_command("mockmatrix 1 2 1") + if not check_no_output(helper, "KB raw"): + return False + # Now release (1, 2) which should cause (2, 1) to be released also + # Expect this is ignored + helper.ec_command("mockmatrix 2 1 0") + helper.ec_command("mockmatrix 1 2 0") + if not check_no_output(helper, "KB raw"): + return False + + # Done testing with (1, 1) and (2, 2). Release them. + helper.ec_command("mockmatrix 1 1 0") + helper.wait_output("KB raw") + helper.ec_command("mockmatrix 2 2 0") + helper.wait_output("KB raw") + + # Press (0, 2) and (1, 1) + helper.ec_command("mockmatrix 0 2 1") + helper.wait_output("KB raw") + helper.ec_command("mockmatrix 1 1 1") + helper.wait_output("KB raw") + + # (0, 1) maps to no key. Pressing (1, 2) and (0, 1) should not be + # deghosted. + helper.ec_command("mockmatrix 1 2 1") + helper.ec_command("mockmatrix 0 1 1") + helper.wait_output("KB raw") + + return True # PASS ! diff --git a/test/kb_deghost.tasklist b/test/kb_deghost.tasklist new file mode 100644 index 0000000000..b5dfe5163c --- /dev/null +++ b/test/kb_deghost.tasklist @@ -0,0 +1,24 @@ +/* Copyright (c) 2011 The Chromium OS Authors. All rights reserved. + * Use of this source code is governed by a BSD-style license that can be + * found in the LICENSE file. + */ + +/** + * List of enabled tasks in the priority order + * + * The first one has the lowest priority. + * + * For each task, use the macro TASK(n, r, d) where : + * 'n' in the name of the task + * 'r' in the main routine of the task + * 'd' in an opaque parameter passed to the routine at startup + */ +#define CONFIG_TASK_LIST \ + TASK(WATCHDOG, watchdog_task, NULL) \ + TASK(PWM, pwm_task, NULL) \ + TASK(TYPEMATIC, keyboard_typematic_task, NULL) \ + TASK(X86POWER, x86_power_task, NULL) \ + TASK(I8042CMD, i8042_command_task, NULL) \ + TASK(KEYSCAN, keyboard_scan_task, NULL) \ + TASK(POWERBTN, power_button_task, NULL) \ + TASK(CONSOLE, console_task, NULL) |