Execute actions in action schedule immediately.

Run next action immediately without using the handler when the requested
delay is zero. This ensures that no other code can run between these two
actions to improve deterministic test behaviour.

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=170456852
This commit is contained in:
tonihei 2017-09-29 01:51:00 -07:00 committed by Oliver Woodman
parent 28173991d1
commit 096d7651d2

View File

@ -16,6 +16,7 @@
package com.google.android.exoplayer2.testutil;
import android.os.Handler;
import android.os.Looper;
import android.view.Surface;
import com.google.android.exoplayer2.C;
import com.google.android.exoplayer2.Player;
@ -342,7 +343,11 @@ public final class ActionSchedule {
this.trackSelector = trackSelector;
this.surface = surface;
this.mainHandler = mainHandler;
clock.postDelayed(mainHandler, this, delayMs);
if (delayMs == 0 && Looper.myLooper() == mainHandler.getLooper()) {
run();
} else {
clock.postDelayed(mainHandler, this, delayMs);
}
}
@Override