diff options
| author | 2023-03-28 21:11:22 +0000 | |
|---|---|---|
| committer | 2023-03-28 21:11:22 +0000 | |
| commit | f89f1c98a5d77a29bab24cc76db6680b60b771db (patch) | |
| tree | 4ea7f02efbdeb2a6d48dcd492758e74610a9422f /java/tests/src | |
| parent | a703bf08aa2212ca0dbefd535e9df92075d20cf4 (diff) | |
| parent | 35828ea4afb4e23fa47c3c6e7c5772c0e59b15ea (diff) | |
Merge "Hide all system actions if there are custom actions." into udc-dev am: 35828ea4af
Original change: https://googleplex-android-review.googlesource.com/c/platform/packages/modules/IntentResolver/+/22314884
Change-Id: Id92703f24d30331c6f9210cd2a06460acaf18fdf
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/contentpreview/ContentPreviewUiTest.kt | 80 |
1 files changed, 80 insertions, 0 deletions
diff --git a/java/tests/src/com/android/intentresolver/contentpreview/ContentPreviewUiTest.kt b/java/tests/src/com/android/intentresolver/contentpreview/ContentPreviewUiTest.kt new file mode 100644 index 00000000..2b78a262 --- /dev/null +++ b/java/tests/src/com/android/intentresolver/contentpreview/ContentPreviewUiTest.kt @@ -0,0 +1,80 @@ +/* + * Copyright (C) 2023 The Android Open Source Project + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package com.android.intentresolver.contentpreview + +import android.content.res.Resources +import android.view.LayoutInflater +import android.view.ViewGroup +import com.android.intentresolver.TestFeatureFlagRepository +import com.android.intentresolver.flags.FeatureFlagRepository +import com.android.intentresolver.flags.Flags +import com.android.intentresolver.widget.ActionRow +import com.google.common.truth.Truth.assertThat +import org.junit.Test + +class ContentPreviewUiTest { + private class TestablePreview(private val flags: FeatureFlagRepository) : ContentPreviewUi() { + override fun getType() = 0 + + override fun display( + resources: Resources?, + layoutInflater: LayoutInflater?, + parent: ViewGroup? + ): ViewGroup { + throw IllegalStateException() + } + + // exposing for testing + fun makeActions( + system: List<ActionRow.Action>, + custom: List<ActionRow.Action> + ): List<ActionRow.Action> { + return createActions(system, custom, flags) + } + } + + @Test + fun testCreateActions() { + val featureFlagRepository = TestFeatureFlagRepository( + mapOf( + Flags.SHARESHEET_CUSTOM_ACTIONS to true + ) + ) + val preview = TestablePreview(featureFlagRepository) + + val system = listOf(ActionRow.Action(label="system", icon=null) {}) + val custom = listOf(ActionRow.Action(label="custom", icon=null) {}) + + assertThat(preview.makeActions(system, custom)).isEqualTo(custom) + assertThat(preview.makeActions(system, listOf())).isEqualTo(system) + } + + @Test + fun testCreateActions_flagDisabled() { + val featureFlagRepository = TestFeatureFlagRepository( + mapOf( + Flags.SHARESHEET_CUSTOM_ACTIONS to false + ) + ) + val preview = TestablePreview(featureFlagRepository) + + val system = listOf(ActionRow.Action(label="system", icon=null) {}) + val custom = listOf(ActionRow.Action(label="custom", icon=null) {}) + + assertThat(preview.makeActions(system, custom)).isEqualTo(system) + } +} |