From a27898b8abdcb59d6d28f72383db0c670ac4a6e8 Mon Sep 17 00:00:00 2001 From: Katherine Blizard <414924+kabliz@users.noreply.github.com> Date: Wed, 4 Sep 2024 15:37:48 -0700 Subject: [PATCH] [APT-10345] Update Tests Attempts to treat downloaded content license renewals similarly to how they are treated when streamed: attempt at renewing the license when playback starts. Also moves the main thread observer to the point in ArmadilloPlayerChoreographer where it is returned, rather than using it in the Reducer. This addresses two problems: the state being inconsistent about which thread it was on, and preventing main thread ANRs. --- .../com/scribd/armadillo/ArmadilloPlayerChoreographer.kt | 7 +++++-- .../scribd/armadillo/ArmadilloPlayerChoreographerTest.kt | 2 +- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/Armadillo/src/main/java/com/scribd/armadillo/ArmadilloPlayerChoreographer.kt b/Armadillo/src/main/java/com/scribd/armadillo/ArmadilloPlayerChoreographer.kt index 1ccfe3f..caa19b3 100644 --- a/Armadillo/src/main/java/com/scribd/armadillo/ArmadilloPlayerChoreographer.kt +++ b/Armadillo/src/main/java/com/scribd/armadillo/ArmadilloPlayerChoreographer.kt @@ -41,6 +41,7 @@ import io.reactivex.Observable import io.reactivex.android.schedulers.AndroidSchedulers import io.reactivex.disposables.CompositeDisposable import io.reactivex.disposables.Disposable +import io.reactivex.subjects.BehaviorSubject import java.util.concurrent.TimeUnit import javax.inject.Inject @@ -214,8 +215,10 @@ internal class ArmadilloPlayerChoreographer : ArmadilloPlayer { /** * emits the most recently emitted state and all the subsequent states when an observer subscribes to it. */ + val armadilloStateSubject: BehaviorSubject + get() = stateProvider.stateSubject override val armadilloStateObservable: Observable - get() = stateProvider.stateSubject.observeOn(AndroidSchedulers.mainThread()) + get() = armadilloStateSubject.observeOn(AndroidSchedulers.mainThread()) private val pollingInterval = Observable.interval(observerPollIntervalMillis.longValue, TimeUnit.MILLISECONDS, AndroidSchedulers.mainThread()) @@ -439,7 +442,7 @@ internal class ArmadilloPlayerChoreographer : ArmadilloPlayer { data class PlaybackReadyData(val transportControls: MediaControllerCompat.TransportControls?, val engineIsReady: Boolean) Log.d(TAG, "Waiting for engine before invoking callback") - disposables.add(armadilloStateObservable + disposables.add(armadilloStateSubject .map { PlaybackReadyData(playbackConnection?.transportControls, it.internalState.isPlaybackEngineReady) } diff --git a/Armadillo/src/test/java/com/scribd/armadillo/ArmadilloPlayerChoreographerTest.kt b/Armadillo/src/test/java/com/scribd/armadillo/ArmadilloPlayerChoreographerTest.kt index 4757353..79c5753 100644 --- a/Armadillo/src/test/java/com/scribd/armadillo/ArmadilloPlayerChoreographerTest.kt +++ b/Armadillo/src/test/java/com/scribd/armadillo/ArmadilloPlayerChoreographerTest.kt @@ -55,7 +55,7 @@ class ArmadilloPlayerChoreographerTest { whenever(stateProvider.stateSubject).thenReturn(stateSubject) choreographer.stateProvider = stateProvider - assertThat(choreographer.armadilloStateObservable.value).isEqualTo(state) + assertThat(choreographer.armadilloStateSubject.value).isEqualTo(state) } @Test