From 096d7651d2b2f1636ee128bda05685009212f0fd Mon Sep 17 00:00:00 2001 From: tonihei Date: Fri, 29 Sep 2017 01:51:00 -0700 Subject: [PATCH] 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 --- .../google/android/exoplayer2/testutil/ActionSchedule.java | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/testutils/src/main/java/com/google/android/exoplayer2/testutil/ActionSchedule.java b/testutils/src/main/java/com/google/android/exoplayer2/testutil/ActionSchedule.java index ba76c58d11..60c13d1947 100644 --- a/testutils/src/main/java/com/google/android/exoplayer2/testutil/ActionSchedule.java +++ b/testutils/src/main/java/com/google/android/exoplayer2/testutil/ActionSchedule.java @@ -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