Use a RAII-style test session to ensure input tests are hermetic
The static InputManagerGlobal instance is created on the first call on getInstance(). It is a static variable because there should only be one instance per process. The old appraoch to testing would reset the existing instance with a test instance, and clear it later. This affects the test state, since the assumption that there is only one real InputManagerGlobal instance per process is broken, as a second instance can be created after clearing. To make these tests hermetic, we use a TestSession tracker to that will be closed at the end of the test, which will replace the test instance with the original one. Bug: 290274722 Test: atest InputTests Change-Id: I5291d5c7097ec741fab37de82c8935096921e1f8
Loading
Please register or sign in to comment