diff options
author | Vic Yang <victoryang@chromium.org> | 2012-07-01 20:33:11 +0800 |
---|---|---|
committer | Gerrit <chrome-bot@google.com> | 2012-07-02 20:36:56 -0700 |
commit | f44db828733e942efeb61305e24231b88ac500b4 (patch) | |
tree | d5e18e6d954a9d6555ab0b6950c8fedf328c7c96 | |
parent | 1bedd55970387fd019c5a6fd368b1576606e8563 (diff) | |
download | chrome-ec-f44db828733e942efeb61305e24231b88ac500b4.tar.gz |
Make 'typematic' test more robust
This test checks the keypress repeat speed. However, there is inevitable
delay incurred by each keypress and thus we cannot be 100% certain about
the number of keypress to expect. Let's set a range instead of expecting
a fixed amount of keypress.
BUG=chrome-os-partner:10287
TEST=Test passed
Change-Id: Ib43bead68e5497cd64251fb45fab522cbaf3ea86
Reviewed-on: https://gerrit.chromium.org/gerrit/26533
Reviewed-by: Randall Spangler <rspangler@chromium.org>
Commit-Ready: Vic Yang <victoryang@chromium.org>
Tested-by: Vic Yang <victoryang@chromium.org>
-rw-r--r-- | test/typematic.py | 24 |
1 files changed, 14 insertions, 10 deletions
diff --git a/test/typematic.py b/test/typematic.py index 97aa8e90ca..6943f43628 100644 --- a/test/typematic.py +++ b/test/typematic.py @@ -17,9 +17,12 @@ def check_no_output(helper, reg_ex): success = True return success -def expect_keypress(helper, cnt): - for i in xrange(cnt + 1): # Plus 1 break code +def expect_keypress(helper, lower_bound, upper_bound): + for i in xrange(lower_bound + 1): # Plus 1 break code helper.wait_output(KEY_PRESS_MSG) + for i in xrange(upper_bound - lower_bound): + if check_no_output(helper, KEY_PRESS_MSG): + return True if not check_no_output(helper, KEY_PRESS_MSG): return False return True @@ -30,6 +33,7 @@ def test(helper): # Enable keyboard scanning helper.ec_command("kbd enable") + time.sleep(0.1) # Workaround for crosbug/p/11015 # Set typematic rate to 1000ms/500ms and hold down a key for 500ms # Expect 1 keypress. @@ -37,31 +41,31 @@ def test(helper): helper.ec_command("mockmatrix 1 1 1") time.sleep(0.5) helper.ec_command("mockmatrix 1 1 0") - if not expect_keypress(helper, 1): + if not expect_keypress(helper, 1, 1): return False # Hold down a key for 1200ms. Expect 2 keypress. helper.ec_command("mockmatrix 1 1 1") time.sleep(1.2) helper.ec_command("mockmatrix 1 1 0") - if not expect_keypress(helper, 2): + if not expect_keypress(helper, 2, 2): return False # Hold down a key for 1700ms. Expect 3 keypress. helper.ec_command("mockmatrix 1 1 1") time.sleep(1.7) helper.ec_command("mockmatrix 1 1 0") - if not expect_keypress(helper, 3): + if not expect_keypress(helper, 3, 3): return False - # Hold down a key for 5400ms. Expect 10 keypress. - # Here we choose 5400ms to allow short delay when each keypress is sent. - # If we choose time length too close to 5000ms, we might end up getting - # only 9 keypress. + # Hold down a key for 5400ms. Expect 9 or 10 keypress. + # Due to inevitable delay incurred by each keypress, we cannot be certain + # about the exact number of keypress. Therefore, mismatching by a small + # amount should be accepted. helper.ec_command("mockmatrix 1 1 1") time.sleep(5.4) helper.ec_command("mockmatrix 1 1 0") - if not expect_keypress(helper, 10): + if not expect_keypress(helper, 9, 10): return False return True # PASS ! |