Initialize the player list after setting up factory injection pattern
Problem: MediaPlayerList leverages MediaSessionManager as an implementation detail, which is marked as final. Bluetooth cannot leverage Mockito extended to mock it, so the real version is used. This causes the state of media on a device to leak into the tests. Some devices, like cars, have preinstalled media applications which can be found (radio, for example). This state was causing unexpected updates to be sent, making many of the never or times calls to be off by 1. Solution: Initizlize the object under test after setting up the factory pattern. This causes the controllers and players made to all be the same mock, which effectively ends up with one object in the map, no matter how many players exist on the device under test. This is because there's check to see if the controller itself exists in the map before adding a new one. This is far from a long term solution, but will get the tests passing again while more structural changes can be prioritized, designed and implemented. Bug: 368171591 Flag: EXEMPT, test only change Test: atest com.android.bluetooth.audio_util.MediaPlayerListTest Change-Id: I0c728173033f18d8bd7140e753b2e28eca2f8d20
Loading
Please register or sign in to comment