Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Skip to content
Commit 20007465 authored by Prabir Pradhan's avatar Prabir Pradhan Committed by Cherrypicker Worker
Browse files

Mock InputDevice in the InputMapper unit tests

This makes the InputMapperUnitTest subclasses easier to test, as the
tests will not have to rely on the behavior of actual InputDevice
implementation.

Unfortunately, this means InputDevice must now be a virtual class to
allow its mocked subclass to define its behavior for the methods that we
want to change. In this CL, we take the approach of only marking the
methods that we need to customize as virtual to avoid the overhead of
vtable lookups at runtime.

An alternative approach would be to introduce a type parameter to
InputDeviceContext to allow us to specify a different InputDevice
implementation in the tests. This would eliminate any addtional runtime
overheads resulting from vtable lookups. However, this would mean every
InputMapper class would need to have this new type parameter, adding
verbosity and complextity to the codebase. For this reason, the virtual
member approach was preferred.

Bug: 354270482
Bug: 353128452
Test: atest inputflinger_tests
Flag: EXEMPT refactor
(cherry picked from https://googleplex-android-review.googlesource.com/q/commit:31d05c4c78e7924e4bb6dc45092e612a9c7d5bfb)
(cherry picked from https://googleplex-android-review.googlesource.com/q/commit:76a4212fb43aa1f6f34e5a03addc5a932defe649)
Merged-In: Id7e103e1f04812c92ee8ecfdfe1e75a9949efa9e
Change-Id: Id7e103e1f04812c92ee8ecfdfe1e75a9949efa9e
parent 44981070
Loading
Loading
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment