Fix test case fail in HearingAidUtilsTest

Root Cause: Only happen when running `make RunSettingsRoboTests` not
happen when running `make RunSettingsRoboTests ROBOTEST_FILTER=HearingAidUtilsTest`. It is dependency test case fail when other tests also have AlertDialog pop up alerady.

Solution: Move ShadowAlertDialog reset before running each test, not after running each test.

Bug: 238829557
Test: make RunSettingsRoboTests
Change-Id: I32da4ee87580b4f475556905f7574b211a69b29b
This commit is contained in:
jasonwshsu
2022-07-13 12:25:23 +08:00
parent 95726e0bad
commit 86c95fc7ab

View File

@@ -28,7 +28,6 @@ import com.android.settings.testutils.shadow.ShadowAlertDialogCompat;
import com.android.settingslib.bluetooth.CachedBluetoothDevice;
import com.android.settingslib.bluetooth.HearingAidProfile;
import org.junit.After;
import org.junit.Before;
import org.junit.Rule;
import org.junit.Test;
@@ -59,12 +58,9 @@ public class HearingAidUtilsTest {
public void setUp() {
final FragmentActivity mActivity = Robolectric.setupActivity(FragmentActivity.class);
mFragmentManager = mActivity.getSupportFragmentManager();
}
@After
public void tearDown() {
ShadowAlertDialogCompat.reset();
}
@Test
public void launchHearingAidPairingDialog_deviceNotConnectedHearingAid_noDialog() {
when(mCachedBluetoothDevice.isConnectedHearingAidDevice()).thenReturn(false);