diff options
| author | 2023-02-10 20:29:23 +0000 | |
|---|---|---|
| committer | 2023-02-10 20:29:23 +0000 | |
| commit | 00bce83c4c0260b2ddc9ebfc7882b59aff82e85b (patch) | |
| tree | c1d8aa6f2843156320f7f1e9d2e0e75b717dd50e /java/tests/src | |
| parent | 4d631bc04cadb56e7631069dbf2cb954dd3e5a6b (diff) | |
| parent | a02b50084f9af3a4b6682eef44f9531708e220e0 (diff) | |
Convert NotSelectableTargetInfo subtree to factories am: 691cfdb494 am: a02b50084f
Original change: https://googleplex-android-review.googlesource.com/c/platform/packages/modules/IntentResolver/+/21339328
Change-Id: I312e33e96c4cb4fbeaeafaf5e0dbc9630d8b467d
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
Diffstat (limited to 'java/tests/src')
| -rw-r--r-- | java/tests/src/com/android/intentresolver/chooser/TargetInfoTest.kt | 24 |
1 files changed, 21 insertions, 3 deletions
diff --git a/java/tests/src/com/android/intentresolver/chooser/TargetInfoTest.kt b/java/tests/src/com/android/intentresolver/chooser/TargetInfoTest.kt index 69948cc9..e9dbe00e 100644 --- a/java/tests/src/com/android/intentresolver/chooser/TargetInfoTest.kt +++ b/java/tests/src/com/android/intentresolver/chooser/TargetInfoTest.kt @@ -22,18 +22,30 @@ import android.content.ComponentName import android.content.Intent import android.content.pm.ActivityInfo import android.content.pm.ResolveInfo +import android.graphics.drawable.AnimatedVectorDrawable import android.os.UserHandle +import android.test.UiThreadTest import androidx.test.platform.app.InstrumentationRegistry import com.android.intentresolver.createChooserTarget import com.android.intentresolver.createShortcutInfo import com.android.intentresolver.mock import com.android.intentresolver.ResolverDataProvider import com.google.common.truth.Truth.assertThat +import org.junit.Before import org.junit.Test class TargetInfoTest { private val context = InstrumentationRegistry.getInstrumentation().getContext() + @Before + fun setup() { + // SelectableTargetInfo reads DeviceConfig and needs a permission for that. + InstrumentationRegistry + .getInstrumentation() + .getUiAutomation() + .adoptShellPermissionIdentity("android.permission.READ_DEVICE_CONFIG") + } + @Test fun testNewEmptyTargetInfo() { val info = NotSelectableTargetInfo.newEmptyTargetInfo() @@ -43,13 +55,19 @@ class TargetInfoTest { assertThat(info.getDisplayIconHolder().getDisplayIcon()).isNull() } + @UiThreadTest // AnimatedVectorDrawable needs to start from a thread with a Looper. @Test fun testNewPlaceholderTargetInfo() { val info = NotSelectableTargetInfo.newPlaceHolderTargetInfo(context) - assertThat(info.isPlaceHolderTargetInfo()).isTrue() - assertThat(info.isChooserTargetInfo()).isTrue() // From legacy inheritance model. + assertThat(info.isPlaceHolderTargetInfo).isTrue() + assertThat(info.isChooserTargetInfo).isTrue() // From legacy inheritance model. assertThat(info.hasDisplayIcon()).isTrue() - // TODO: test infrastructure isn't set up to assert anything about the icon itself. + assertThat(info.displayIconHolder.displayIcon) + .isInstanceOf(AnimatedVectorDrawable::class.java) + // TODO: assert that the animation is pre-started/running (IIUC this requires synchronizing + // with some "render thread" per the `AnimatedVectorDrawable` docs). I believe this is + // possible using `AnimatorTestRule` but I couldn't find any sample usage in Kotlin nor get + // it working myself. } @Test |