diff options
author | 2023-06-02 07:01:13 +0000 | |
---|---|---|
committer | 2023-06-02 07:01:13 +0000 | |
commit | 85b17308f4e3a57c32df9cb3f8da6e75d0f9d799 (patch) | |
tree | 0559bb080ad571e848ce67284afe58280a3022fd | |
parent | b23784f8473a5dab3a626b800dea9e02b929573e (diff) | |
parent | e349b03dd98ab400ec3e1bf84742efd299d9ca79 (diff) |
Merge "Add noMoreOptions param to AppListPage" into udc-dev am: e349b03dd9
Original change: https://googleplex-android-review.googlesource.com/c/platform/frameworks/base/+/23493104
Change-Id: Ib8d5d83e85d3c696ac1399b7d3df011aa2683a85
Signed-off-by: Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
2 files changed, 33 insertions, 12 deletions
diff --git a/packages/SettingsLib/SpaPrivileged/src/com/android/settingslib/spaprivileged/template/app/AppListPage.kt b/packages/SettingsLib/SpaPrivileged/src/com/android/settingslib/spaprivileged/template/app/AppListPage.kt index 89bfa0eb646b..030b70a75a8b 100644 --- a/packages/SettingsLib/SpaPrivileged/src/com/android/settingslib/spaprivileged/template/app/AppListPage.kt +++ b/packages/SettingsLib/SpaPrivileged/src/com/android/settingslib/spaprivileged/template/app/AppListPage.kt @@ -31,6 +31,8 @@ import com.android.settingslib.spaprivileged.template.common.UserProfilePager /** * The full screen template for an App List page. * + * @param noMoreOptions default false. If true, then do not display more options action button, + * including the "Show System" / "Hide System" action. * @param header the description header appears before all the applications. */ @Composable @@ -38,6 +40,7 @@ fun <T : AppRecord> AppListPage( title: String, listModel: AppListModel<T>, showInstantApps: Boolean = false, + noMoreOptions: Boolean = false, matchAnyUserForAdmin: Boolean = false, primaryUserOnly: Boolean = false, noItemMessage: String? = null, @@ -49,9 +52,11 @@ fun <T : AppRecord> AppListPage( SearchScaffold( title = title, actions = { - MoreOptionsAction { - ShowSystemAction(showSystem.value) { showSystem.value = it } - moreOptions() + if (!noMoreOptions) { + MoreOptionsAction { + ShowSystemAction(showSystem.value) { showSystem.value = it } + moreOptions() + } } }, ) { bottomPadding, searchQuery -> diff --git a/packages/SettingsLib/SpaPrivileged/tests/src/com/android/settingslib/spaprivileged/template/app/AppListPageTest.kt b/packages/SettingsLib/SpaPrivileged/tests/src/com/android/settingslib/spaprivileged/template/app/AppListPageTest.kt index 06003c0cb8f9..f6f48891030a 100644 --- a/packages/SettingsLib/SpaPrivileged/tests/src/com/android/settingslib/spaprivileged/template/app/AppListPageTest.kt +++ b/packages/SettingsLib/SpaPrivileged/tests/src/com/android/settingslib/spaprivileged/template/app/AppListPageTest.kt @@ -63,9 +63,7 @@ class AppListPageTest { fun canShowSystem() { val inputState by setContent() - composeTestRule.onNodeWithContentDescription( - context.getString(R.string.abc_action_menu_overflow_description) - ).performClick() + onMoreOptions().performClick() composeTestRule.onNodeWithText(context.getString(R.string.menu_show_system)).performClick() val state = inputState!!.state @@ -75,20 +73,32 @@ class AppListPageTest { @Test fun afterShowSystem_displayHideSystem() { setContent() - composeTestRule.onNodeWithContentDescription( - context.getString(R.string.abc_action_menu_overflow_description) - ).performClick() + onMoreOptions().performClick() composeTestRule.onNodeWithText(context.getString(R.string.menu_show_system)).performClick() - composeTestRule.onNodeWithContentDescription( - context.getString(R.string.abc_action_menu_overflow_description) - ).performClick() + onMoreOptions().performClick() composeTestRule.onNodeWithText(context.getString(R.string.menu_hide_system)) .assertIsDisplayed() } + @Test + fun noMoreOptions_notDisplayMoreOptions() { + setContent(noMoreOptions = true) + + onMoreOptions().assertDoesNotExist() + } + + @Test + fun noMoreOptions_showSystemIsFalse() { + val inputState by setContent(noMoreOptions = true) + + val state = inputState!!.state + assertThat(state.showSystem.value).isFalse() + } + private fun setContent( + noMoreOptions: Boolean = false, header: @Composable () -> Unit = {}, ): State<AppListInput<TestAppRecord>?> { val appListState = mutableStateOf<AppListInput<TestAppRecord>?>(null) @@ -96,6 +106,7 @@ class AppListPageTest { AppListPage( title = TITLE, listModel = TestAppListModel(), + noMoreOptions = noMoreOptions, header = header, appList = { appListState.value = this }, ) @@ -103,6 +114,11 @@ class AppListPageTest { return appListState } + private fun onMoreOptions() = + composeTestRule.onNodeWithContentDescription( + context.getString(R.string.abc_action_menu_overflow_description) + ) + private companion object { const val TITLE = "Title" } |