Files
proton-stream/android/app/src/test/java/io/narl/protonstream/IncomingShareLinkTest.kt
T
nvrl 8a1807c262 feat(android): open share links from a browser or the share sheet
A drive.proton.me/urls/ link opened from a browser, or text containing
one shared to the app, switches to Shares and opens the Add form with
the link filled in, fragment included. A playing episode moves to the
mini transport instead of covering the form. A recreated activity does
not offer the same link again.

The view filter is not autoVerify, since the domain is Proton's, so
Android only routes browser links here once "Open supported links" is
allowed in the app's settings; sharing works without that.
2026-10-03 03:59:41 +02:00

38 lines
1.2 KiB
Kotlin

package io.narl.protonstream
import android.content.Intent
import org.junit.Assert.assertEquals
import org.junit.Assert.assertNull
import org.junit.Test
class IncomingShareLinkTest {
private val link = "https://drive.proton.me/urls/ABC123#s3cr3t"
@Test
fun `a viewed share link is taken whole, fragment included`() {
assertEquals(link, shareLinkFrom(Intent.ACTION_VIEW, link, null))
}
@Test
fun `a viewed url that is not an https share link is ignored`() {
assertNull(shareLinkFrom(Intent.ACTION_VIEW, "https://drive.proton.me/u/0/", null))
assertNull(shareLinkFrom(Intent.ACTION_VIEW, "http://drive.proton.me/urls/ABC123#s3cr3t", null))
}
@Test
fun `a shared message yields the link inside it`() {
assertEquals(link, shareLinkFrom(Intent.ACTION_SEND, null, "Season two is up: $link enjoy"))
assertEquals(link, shareLinkFrom(Intent.ACTION_SEND, null, "(<$link>)"))
}
@Test
fun `a shared message without a link yields nothing`() {
assertNull(shareLinkFrom(Intent.ACTION_SEND, null, "no link here"))
}
@Test
fun `other actions are ignored`() {
assertNull(shareLinkFrom(Intent.ACTION_MAIN, link, link))
}
}