summaryrefslogtreecommitdiff
path: root/java/tests/src
diff options
context:
space:
mode:
author Joshua Trask <joshtrask@google.com> 2022-10-20 09:18:06 -0400
committer Joshua Trask <joshtrask@google.com> 2022-10-24 13:28:25 +0000
commitdeb9ddfb590c7533e1be565c40f9a522071c19a9 (patch)
treee73c8b845c66d66212731e7d64c09abcd85f0e30 /java/tests/src
parent5551f9d425395ae427c98785425b81a32b1103dd (diff)
Rename & pull `getTargets` up to base `TargetInfo`
This was originally only offered on `MultiDisplayResolveInfo` but that just resulted in some type-checked conditional logic where the caller (`ChooserActivity`) took responsibility for implementing the other cases. Thus this CL is mainly based on the "Replace Conditional with Polymorphism" item in Fowler's _Refactoring_. (It also separates one piece of unrelated conditional behavior from the call site in `ChooserActivity` but leaves any further cleanup of that separate behavior out of scope.) The method rename is an attempt to call attention to the use of the legacy `DisplayResolveInfo` type (as distinguished from other types of "targets" i.e. `ChooserTargetInfo`), in advance of any cleanup of that design. This both simplifies the call site (in `ChooserActivity`) and consolidates `TargetInfo` requirements that were previously diffuse. It also progresses several of our tactical goals in the ongoing `TargetInfo` cleanup (go/chooser-targetinfo-cleanup): * In order to unify the types, all methods offered by any `TargetInfo` implementation have to be pulled up to the base interface; this CL prioritizes one method of particular benefit to callers in its new location, but it was going to have to move eventually regardless. * This encapsulates one of the two call sites of `TargetInfo.getDisplayResolveInfo()`. That API assumes callers have an understanding of the semantics of the legacy `DisplayResolveInfo` implementation, along with the semantics of the (legacy) concrete type of any other `TargetInfo` they might hold (in order to know whether they can use it as-is vs. descending through its `getDisplayResolveInfo()`). The new API focuses (slightly) more on the application requirements that client is trying to fulfill. * More broadly, this reduces call sites where clients depend on the (new-but-deprecated) `TargetInfo` methods that query the legacy type information. These usages _all_ need to be replaced with new APIs that are more expressive in the application domain. Test: atest IntentResolverUnitTests Bug: 202167050 Change-Id: Ibc6cbfb01f323db4b820053babfeb5f7c8024f26
Diffstat (limited to 'java/tests/src')
-rw-r--r--java/tests/src/com/android/intentresolver/chooser/TargetInfoTest.kt3
1 files changed, 2 insertions, 1 deletions
diff --git a/java/tests/src/com/android/intentresolver/chooser/TargetInfoTest.kt b/java/tests/src/com/android/intentresolver/chooser/TargetInfoTest.kt
index 8494e296..4a5e1baf 100644
--- a/java/tests/src/com/android/intentresolver/chooser/TargetInfoTest.kt
+++ b/java/tests/src/com/android/intentresolver/chooser/TargetInfoTest.kt
@@ -122,7 +122,8 @@ class TargetInfoTest {
assertThat(multiTargetInfo.getExtendedInfo()).isNull()
- assertThat(multiTargetInfo.getTargets()).containsExactly(firstTargetInfo, secondTargetInfo)
+ assertThat(multiTargetInfo.getAllDisplayTargets())
+ .containsExactly(firstTargetInfo, secondTargetInfo)
assertThat(multiTargetInfo.hasSelected()).isFalse()
assertThat(multiTargetInfo.getSelectedTarget()).isNull()