firmware_TouchMTB: add MtbSanityValidator

This patch checks two things.

1. Ghost fingers:
   The validator checks if there exist ghost fingers before fingers
   touch the touch device. This is accomplished by querying the
   InputDevice class which syncs with the kernel evdev driver about
   the mt slots information.

2. MTB event rules:
   The MTB events emitted by a device have to follow some rules.
   Otherwise, the events may confuse the state machine in the MTB
   parser. As a beginning, this validator checks some simple rules:

   a. No TRACKING ID is set to -1 before a slot is assigned a
      positive TRACKING ID value.

   b. No X, Y, or PRESSURE values could be assigned to a slot
      before the slot is assigned a positive TRACKING ID value.

   More rules may be added to this validator when needed.

Note that item 1 above is to detect any pre-existing fingers
before the test is conducted, while item 2 is to detect any event
mis-ordering or corruption occurring during the test.

BUG=chrome-os-partner:30965
TEST=All unit tests should pass on a chromebook.
$ cd /usr/local/autotest/tests/firmware_TouchMTB
$ python tests/run_all_unittests.py

Change-Id: Id85dcb8e54601f5dfd6d77bbf3802fdcb2d74a60
Reviewed-on: https://chromium-review.googlesource.com/210792
Reviewed-by: Charles Mooney <charliemooney@chromium.org>
Commit-Queue: Shyh-In Hwang <josephsih@chromium.org>
Tested-by: Shyh-In Hwang <josephsih@chromium.org>
10 files changed