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

Commit 74c4723e authored by Sungsoo Lim's avatar Sungsoo Lim
Browse files

Add a ProfileServiceTest

If the profile services haven't been started,
onProfileServiceStateChanged() shouldn't be called when
the start intent comes with STATE_OFF.

Bug: 267387873
Test: atest BluetoothInstrumentationTest:ProfileServiceTest
Change-Id: Ibc29d2974ec8a41998ed630106938e498cff6959
parent 63454f8e
Loading
Loading
Loading
Loading
+14 −0
Original line number Diff line number Diff line
@@ -78,6 +78,11 @@ public class ProfileServiceTest {
        for (Class profile : mProfiles) {
            setProfileState(profile, state);
        }
        if (invocationNumber == 0) {
            verify(mMockAdapterService, after(PROFILE_START_MILLIS).never())
                    .onProfileServiceStateChanged(any(), anyInt());
            return;
        }
        ArgumentCaptor<ProfileService> argument = ArgumentCaptor.forClass(ProfileService.class);
        verify(mMockAdapterService, timeout(PROFILE_START_MILLIS).times(
                mProfiles.length * invocationNumber)).onProfileServiceStateChanged(
@@ -235,4 +240,13 @@ public class ProfileServiceTest {
            profileNumber += 1;
        }
    }

    /**
     * Test: Stop the Bluetooth profile services that are not started.
     * Verify that the profile service state is not changed.
     */
    @Test
    public void testDisable() throws TimeoutException {
        setAllProfilesState(BluetoothAdapter.STATE_OFF, 0);
    }
}