summaryrefslogtreecommitdiff
path: root/java/tests
diff options
context:
space:
mode:
author Joshua Trask <joshtrask@google.com> 2023-02-09 18:26:37 +0000
committer Joshua Trask <joshtrask@google.com> 2023-02-09 21:18:24 +0000
commit031a84bc72c2f8d5483fefc24539bb5ee08d5fdc (patch)
tree3f2f0ae3a379712d4864325e69d4ad345e9cc54b /java/tests
parent691cfdb494fd6d4e194b1e9dc07470ab64564bfe (diff)
Remove plain `startActivity` plumbing APIs
These were unused, and the pruned-down API surface better indicates that we *always* launch activities to an explicit *user* (and *maybe* with additional specification about the caller identity -- something to do with the "safe forwarding mode" feature I'm still trying to get my mind aroud). While I was in here, I changed the signature of the one 'activity starter' method that arbitrarily took a `ResolverActivity` instead of the more generic `Activity` used in the others. We've been commenting about the opportunity to make this fix for a while now, and there's no time like the present. Test: `atest IntentResolverUnitTests` Bug: 202167050 Change-Id: I33be96b68e6feba8b7fdb0295431373aadd2c2bf
Diffstat (limited to 'java/tests')
-rw-r--r--java/tests/src/com/android/intentresolver/chooser/ImmutableTargetInfoTest.kt54
1 files changed, 2 insertions, 52 deletions
diff --git a/java/tests/src/com/android/intentresolver/chooser/ImmutableTargetInfoTest.kt b/java/tests/src/com/android/intentresolver/chooser/ImmutableTargetInfoTest.kt
index 4d825f6b..4989a3f1 100644
--- a/java/tests/src/com/android/intentresolver/chooser/ImmutableTargetInfoTest.kt
+++ b/java/tests/src/com/android/intentresolver/chooser/ImmutableTargetInfoTest.kt
@@ -349,42 +349,8 @@ class ImmutableTargetInfoTest {
}
@Test
- fun testActivityStarter_correctNumberOfInvocations_start() {
- val activityStarter = object : TestActivityStarter() {
- override fun startAsCaller(
- target: TargetInfo, activity: Activity, options: Bundle, userId: Int): Boolean {
- throw RuntimeException("Wrong API used: startAsCaller")
- }
-
- override fun startAsUser(
- target: TargetInfo, activity: Activity, options: Bundle, user: UserHandle
- ): Boolean {
- throw RuntimeException("Wrong API used: startAsUser")
- }
- }
-
- val info = ImmutableTargetInfo.newBuilder().setActivityStarter(activityStarter).build()
- val activity: Activity = mock()
- val options = Bundle()
- options.putInt("TEST_KEY", 1)
-
- info.start(activity, options)
-
- assertThat(activityStarter.totalInvocations).isEqualTo(1)
- assertThat(activityStarter.lastInvocationTargetInfo).isEqualTo(info)
- assertThat(activityStarter.lastInvocationActivity).isEqualTo(activity)
- assertThat(activityStarter.lastInvocationOptions).isEqualTo(options)
- assertThat(activityStarter.lastInvocationUserId).isNull()
- assertThat(activityStarter.lastInvocationAsCaller).isFalse()
- }
-
- @Test
fun testActivityStarter_correctNumberOfInvocations_startAsCaller() {
val activityStarter = object : TestActivityStarter() {
- override fun start(target: TargetInfo, activity: Activity, options: Bundle): Boolean {
- throw RuntimeException("Wrong API used: start")
- }
-
override fun startAsUser(
target: TargetInfo, activity: Activity, options: Bundle, user: UserHandle
): Boolean {
@@ -410,10 +376,6 @@ class ImmutableTargetInfoTest {
@Test
fun testActivityStarter_correctNumberOfInvocations_startAsUser() {
val activityStarter = object : TestActivityStarter() {
- override fun start(target: TargetInfo, activity: Activity, options: Bundle): Boolean {
- throw RuntimeException("Wrong API used: start")
- }
-
override fun startAsCaller(
target: TargetInfo, activity: Activity, options: Bundle, userId: Int): Boolean {
throw RuntimeException("Wrong API used: startAsCaller")
@@ -441,16 +403,14 @@ class ImmutableTargetInfoTest {
val info1 = ImmutableTargetInfo.newBuilder().setActivityStarter(activityStarter).build()
val info2 = info1.toBuilder().build()
- info1.start(mock(), Bundle())
+ info1.startAsCaller(mock(), Bundle(), 42)
assertThat(activityStarter.lastInvocationTargetInfo).isEqualTo(info1)
- info2.start(mock(), Bundle())
- assertThat(activityStarter.lastInvocationTargetInfo).isEqualTo(info2)
info2.startAsCaller(mock(), Bundle(), 42)
assertThat(activityStarter.lastInvocationTargetInfo).isEqualTo(info2)
info2.startAsUser(mock(), Bundle(), UserHandle.of(42))
assertThat(activityStarter.lastInvocationTargetInfo).isEqualTo(info2)
- assertThat(activityStarter.totalInvocations).isEqualTo(4) // Instance is still shared.
+ assertThat(activityStarter.totalInvocations).isEqualTo(3) // Instance is still shared.
}
}
@@ -462,16 +422,6 @@ private open class TestActivityStarter : ImmutableTargetInfo.TargetActivityStart
var lastInvocationUserId: Integer? = null
var lastInvocationAsCaller = false
- override fun start(target: TargetInfo, activity: Activity, options: Bundle): Boolean {
- ++totalInvocations
- lastInvocationTargetInfo = target
- lastInvocationActivity = activity
- lastInvocationOptions = options
- lastInvocationUserId = null
- lastInvocationAsCaller = false
- return true
- }
-
override fun startAsCaller(
target: TargetInfo, activity: Activity, options: Bundle, userId: Int): Boolean {
++totalInvocations