diff options
author | 2024-08-01 14:56:31 -0700 | |
---|---|---|
committer | 2024-08-15 11:41:15 -0700 | |
commit | 754d59681277b2afdd52b79746a593488f132e4b (patch) | |
tree | 73c52de4857c9f943bea1cf7524a422aa02fb1d6 /tests | |
parent | 2f6086166956949bc5ab732795f671b1800cb613 (diff) |
Allow toggling of final shareousel item
When no items selected the UI will:
* change the chooser headline;
* make the custom action row invisible;
* make all targets disabled and all target icons greyscale.
Fix: 349468879
Test: atest IntentResolver-tests-unit
Test: manual functionality testing
Flag: com.android.intentresolver.unselect_final_item
Change-Id: I53b9c908943b1f1003cb0131a6dec8abc26ec782
Diffstat (limited to 'tests')
2 files changed, 37 insertions, 0 deletions
diff --git a/tests/unit/src/com/android/intentresolver/contentpreview/payloadtoggle/domain/interactor/SelectionInteractorTest.kt b/tests/unit/src/com/android/intentresolver/contentpreview/payloadtoggle/domain/interactor/SelectionInteractorTest.kt index 87db243d..c8242333 100644 --- a/tests/unit/src/com/android/intentresolver/contentpreview/payloadtoggle/domain/interactor/SelectionInteractorTest.kt +++ b/tests/unit/src/com/android/intentresolver/contentpreview/payloadtoggle/domain/interactor/SelectionInteractorTest.kt @@ -18,16 +18,24 @@ package com.android.intentresolver.contentpreview.payloadtoggle.domain.interacto import android.content.Intent import android.net.Uri +import android.platform.test.annotations.DisableFlags +import android.platform.test.annotations.EnableFlags +import android.platform.test.flag.junit.SetFlagsRule +import com.android.intentresolver.Flags import com.android.intentresolver.contentpreview.mimetypeClassifier import com.android.intentresolver.contentpreview.payloadtoggle.data.repository.previewSelectionsRepository import com.android.intentresolver.contentpreview.payloadtoggle.shared.model.PreviewModel import com.android.intentresolver.util.runKosmosTest import com.google.common.truth.Truth.assertThat import kotlinx.coroutines.flow.first +import org.junit.Rule import org.junit.Test class SelectionInteractorTest { + @get:Rule val flagsRule = SetFlagsRule() + @Test + @DisableFlags(Flags.FLAG_UNSELECT_FINAL_ITEM) fun singleSelection_removalPrevented() = runKosmosTest { val initialPreview = PreviewModel( @@ -54,6 +62,33 @@ class SelectionInteractorTest { } @Test + @EnableFlags(Flags.FLAG_UNSELECT_FINAL_ITEM) + fun singleSelection_itemRemovedNoPendingIntentUpdates() = runKosmosTest { + val initialPreview = + PreviewModel( + uri = Uri.fromParts("scheme", "ssp", "fragment"), + mimeType = null, + order = 0 + ) + previewSelectionsRepository.selections.value = mapOf(initialPreview.uri to initialPreview) + + val underTest = + SelectionInteractor( + previewSelectionsRepository, + { Intent() }, + updateTargetIntentInteractor, + mimetypeClassifier, + ) + + assertThat(underTest.selections.first()).containsExactly(initialPreview.uri) + + underTest.unselect(initialPreview) + + assertThat(underTest.selections.first()).isEmpty() + assertThat(previewSelectionsRepository.selections.value).isEmpty() + } + + @Test fun multipleSelections_removalAllowed() = runKosmosTest { val first = PreviewModel( diff --git a/tests/unit/src/com/android/intentresolver/contentpreview/payloadtoggle/ui/viewmodel/ShareouselViewModelTest.kt b/tests/unit/src/com/android/intentresolver/contentpreview/payloadtoggle/ui/viewmodel/ShareouselViewModelTest.kt index 1047d145..fc7ac751 100644 --- a/tests/unit/src/com/android/intentresolver/contentpreview/payloadtoggle/ui/viewmodel/ShareouselViewModelTest.kt +++ b/tests/unit/src/com/android/intentresolver/contentpreview/payloadtoggle/ui/viewmodel/ShareouselViewModelTest.kt @@ -347,6 +347,8 @@ class ShareouselViewModelTest { override fun getVideosHeadline(count: Int): String = "VIDEOS: $count" override fun getFilesHeadline(count: Int): String = "FILES: $count" + + override fun getNotItemsSelectedHeadline() = "Select items to share" } // instantiate the view model, and then runCurrent() so that it is fully hydrated before // starting the test |