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

Commit 60b0d3df authored by Jakub Tyszkowski's avatar Jakub Tyszkowski
Browse files

VolumeControl: Make tests tearDown more robust

Bug: 329389028
Test: atest BluetoothInstrumentationTests
Flag: Exempt; test only changes
Change-Id: I8e9debd5af21507348d8ff8f41f73dcf632bf932
parent c779336a
Loading
Loading
Loading
Loading
+10 −3
Original line number Diff line number Diff line
@@ -57,7 +57,7 @@ import org.mockito.junit.MockitoRule;
@RunWith(AndroidJUnit4.class)
public class VolumeControlStateMachineTest {
    private BluetoothAdapter mAdapter;
    private HandlerThread mHandlerThread;
    private HandlerThread mHandlerThread = null;
    private VolumeControlStateMachine mVolumeControlStateMachine;
    private BluetoothDevice mTestDevice;
    private static final int TIMEOUT_MS = 1000;
@@ -68,6 +68,8 @@ public class VolumeControlStateMachineTest {
    @Mock private VolumeControlService mVolumeControlService;
    @Mock private VolumeControlNativeInterface mVolumeControlNativeInterface;

    boolean mIsAdapterServiceSet;

    @Before
    public void setUp() throws Exception {
        InstrumentationRegistry.getInstrumentation()
@@ -76,6 +78,7 @@ public class VolumeControlStateMachineTest {
        TestUtils.setAdapterService(mAdapterService);

        mAdapter = BluetoothAdapter.getDefaultAdapter();
        mIsAdapterServiceSet = true;

        // Get a device for testing
        mTestDevice = mAdapter.getRemoteDevice("00:01:02:03:04:05");
@@ -96,9 +99,13 @@ public class VolumeControlStateMachineTest {

    @After
    public void tearDown() throws Exception {
        if (mHandlerThread != null) {
            mHandlerThread.quit();
        }
        if (mIsAdapterServiceSet) {
            TestUtils.clearAdapterService(mAdapterService);
        }
    }

    /** Test that default state is disconnected */
    @Test