prep merge tv-trailer-intent
This commit is contained in:
commit
8b6edf5a96
2 changed files with 8 additions and 5 deletions
|
|
@ -19,21 +19,23 @@ import org.robolectric.annotation.Config
|
|||
@Config(sdk = [34], application = Application::class)
|
||||
class TitleTrailerTest {
|
||||
private val context = ApplicationProvider.getApplicationContext<Context>()
|
||||
private val url = "https://www.youtube.com/watch?v=abcdefghijk"
|
||||
private val url = "https://www.youtube.com/watch?v=ab_-defghij"
|
||||
|
||||
@Test fun missingYoutubeHandlerStaysOnTheTitleEvenWhenABrowserExists() {
|
||||
register(Intent(Intent.ACTION_VIEW, Uri.parse(url)), "test.browser")
|
||||
register(Intent(Intent.ACTION_VIEW, Uri.parse("https://www.youtube.com/watch?v=ab_-defghij")), "test.browser")
|
||||
assertFalse(TitleTrailer(context).open(url))
|
||||
assertNull(shadowOf(context as Application).nextStartedActivity)
|
||||
}
|
||||
|
||||
@Test fun installedYoutubeHandlerReceivesAnExplicitPackageAndNoBrowserUrl() {
|
||||
register(Intent(Intent.ACTION_VIEW, Uri.parse("vnd.youtube:abcdefghijk")), "test.youtube")
|
||||
register(Intent(Intent.ACTION_VIEW, Uri.parse("vnd.youtube://ab_-defghij")), "test.youtube")
|
||||
assertTrue(TitleTrailer(context).open(url))
|
||||
val launched = shadowOf(context as Application).nextStartedActivity
|
||||
assertEquals(Intent.ACTION_VIEW, launched.action)
|
||||
assertEquals("test.youtube", launched.`package`)
|
||||
assertEquals("vnd.youtube", launched.data?.scheme)
|
||||
assertEquals("abcdefghijk", launched.data?.schemeSpecificPart)
|
||||
// SmartTube (IntentExtractor.extractVideoId) takes the id from Uri.getHost() for this scheme; the opaque `vnd.youtube:ID` form yields null there.
|
||||
assertEquals("ab_-defghij", launched.data?.host)
|
||||
}
|
||||
|
||||
@Test fun nonYoutubeTrailerNeverOpensAGeneralViewHandler() {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue