-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
f0b8619
commit a0f1aea
Showing
5 changed files
with
75 additions
and
58 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
18 changes: 18 additions & 0 deletions
18
...aTestApp/src/androidTest/java/com/bitmovin/analytics/conviva/testapp/framework/Sources.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
package com.bitmovin.analytics.conviva.testapp.framework | ||
|
||
import com.bitmovin.player.api.source.SourceConfig | ||
import com.bitmovin.player.api.source.SourceType | ||
|
||
object Sources { | ||
object Ads { | ||
const val VMAP_PREROLL_SINGLE_TAG = "https://pubads.g.doubleclick.net/gampad/ads?sz=640x480&iu=/124319096/external/ad_rule_samples&ciu_szs=300x250&ad_rule=1&impl=s&gdfp_req=1&env=vp&output=vmap&unviewed_position_start=1&cust_params=deployment%3Ddevsite%26sample_ar%3Dpreonly&cmsid=496&vid=short_onecue&correlator=" | ||
} | ||
|
||
object Dash { | ||
val basic = SourceConfig( | ||
url = "https://bitmovin-a.akamaihd.net/content/MI201109210084_1/mpds/f08e80da-bf1d-4e3d-8899-f0f6155f6efa.mpd", | ||
type = SourceType.Dash, | ||
title = "Art of Motion Test Stream", | ||
) | ||
} | ||
} |
43 changes: 43 additions & 0 deletions
43
...src/androidTest/java/com/bitmovin/analytics/conviva/testapp/framework/TestingFramework.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
package com.bitmovin.analytics.conviva.testapp.framework | ||
|
||
import android.os.Handler | ||
import com.bitmovin.player.api.Player | ||
import com.bitmovin.player.api.event.Event | ||
import com.bitmovin.player.api.event.EventEmitter | ||
import com.bitmovin.player.api.event.on | ||
import kotlinx.coroutines.runBlocking | ||
import kotlin.coroutines.resume | ||
import kotlin.coroutines.suspendCoroutine | ||
|
||
const val BITMOVIN_PLAYER_LICENSE_KEY = "YOUR_LICENSE_KEY" | ||
const val CONVIVA_CUSTOMER_KEY = "YOUR-CUSTOMER-KEY" | ||
const val CONVIVA_GATEWAY_URL = "YOUR-GATEWAY-URL" | ||
|
||
|
||
/** | ||
* Subscribes to an [Event] on the [Player] and suspends until the event is emitted. | ||
* Optionally a [condition] can be provided to filter the emitted events. | ||
*/ | ||
inline fun <reified T : Event> EventEmitter<Event>.expectEvent( | ||
crossinline condition: (T) -> Boolean = { true } | ||
) = runBlocking { | ||
suspendCoroutine { continuation -> | ||
lateinit var action: ((T) -> Unit) | ||
action = { | ||
if (condition(it)) { | ||
off(action) | ||
continuation.resume(Unit) | ||
} | ||
} | ||
on<T>(action) | ||
} | ||
} | ||
|
||
/** | ||
* Posts a [block] of code to the main thread and suspends until it is executed. | ||
*/ | ||
inline fun <T> Handler.postWaiting(crossinline block: () -> T) = runBlocking { | ||
suspendCoroutine { continuation -> | ||
post { continuation.resume(block()) } | ||
} | ||
} |