Skip to content

Commit

Permalink
[APT-10345] Update Tests
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
kabliz committed Sep 4, 2024
1 parent 6ef5275 commit a27898b
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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<ArmadilloState>
get() = stateProvider.stateSubject
override val armadilloStateObservable: Observable<ArmadilloState>
get() = stateProvider.stateSubject.observeOn(AndroidSchedulers.mainThread())
get() = armadilloStateSubject.observeOn(AndroidSchedulers.mainThread())

private val pollingInterval =
Observable.interval(observerPollIntervalMillis.longValue, TimeUnit.MILLISECONDS, AndroidSchedulers.mainThread())
Expand Down Expand Up @@ -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)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit a27898b

Please sign in to comment.