Use FakeTimer in test to avoid flakiness.
**Root cause** ScreenFlashNotificationColorDialogFragment creates Timer which spawns unmanageable threads for tests. Also, the test itself uses Thread.sleep which makes it non-destermistic. Bug: 279082331 Test: atest ScreenFlashNotificationColorDialogFragmentTest --iteration 20 Change-Id: Id49c8d402a0578f8297ca12fe49da304c7a988d8
This commit is contained in:
@@ -119,7 +119,7 @@ public class ScreenFlashNotificationColorDialogFragment extends DialogFragment i
|
||||
synchronized (this) {
|
||||
if (mTimer != null) mTimer.cancel();
|
||||
|
||||
mTimer = new Timer();
|
||||
mTimer = createTimer();
|
||||
if (mIsPreview) {
|
||||
mTimer.schedule(getStopTask(), 0);
|
||||
startDelay = BETWEEN_STOP_AND_START_DELAY_MS;
|
||||
@@ -176,4 +176,8 @@ public class ScreenFlashNotificationColorDialogFragment extends DialogFragment i
|
||||
getContext().sendBroadcast(stopIntent);
|
||||
mIsPreview = false;
|
||||
}
|
||||
|
||||
Timer createTimer() {
|
||||
return new Timer();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user