Don't use real state machines when testing clean up
Problem: The test in question was instantiating a *real* state machine to test the in function call to cleanupDevice() when a state machine calls to remove itself when it disconnects. It was loading a mock into the map and using the real state machine to eventually invoke the function it wanted to test. The real state machine was trying to use real telephony (which should be mocked) and was prone to failing. This was causing downstream issues where the MMS/SMS DB abstraction couldn't be created, which threw an exception and left the object null. When cleanup time happened, mDatabase.cleanup() would throw an NPE, further hiding the issue. Solution: Just don't use a real object. Rather then get our mocks in place for Telephony or changing the code to better handle the Telephony stack's ability to fail (which are both things we *should* do eventually), its far easier to test the code path in question with two mock state machines. There's no reason not to. We get the same coverage without the errors, and its simpler/less errorprone Bug: 367386196 Flag: EXEMPT, test change only Test: atest com.android.bluetooth.mapclient.MapClientServiceTest Change-Id: I19513f58b0b6e34cb2bd61d77267d2c135ac6809
Loading
Please register or sign in to comment