Loading
TestLooper: Some changes to test looper behavior
a) Add a new stopAutoDispatchAndIgnoreExceptions method This method ignores exceptions raised when there are no messages dispatched in the looper. Helps write negative unit tests for methods where the runnables are not posted when some preconditions are not met. Not starting the looper in these tests would make it unclear whether the test failed because the looper was not running or because the preconditions (like permission checks) where not satisfied. b) Auto dispatch will only stop running when stopAutoDispatch is invoked. Previously it stops running when it runs a single message. This causes failures in unit tests for methods which posts multiple runnables in the same method. Bug: 138403307 Bug: 117601161 Test: atest com.android.server.wifi Change-Id: Iab27d92d443c6d7364c52b86d51dd2cb7902358a