summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author Chaohui Wang <chaohuiw@google.com> 2023-06-01 17:14:24 +0800
committer Chaohui Wang <chaohuiw@google.com> 2023-06-01 09:20:42 +0000
commit37073bff8f166dccfd8106cf0a8940d12ba24d03 (patch)
tree1cf348f0778bbaeb508b4492b9df6d161e241f82
parent4c45ee8c1d558d14ab4588d7616bcf7aa518438d (diff)
Add noMoreOptions param to AppListPage
Default false. If true, then do not display more options action button, including the "Show System" / "Hide System" action. Bug: 285264906 Test: Unit test Change-Id: I6e6c15275c428e66c45bf0da68a562a7319e3934
-rw-r--r--packages/SettingsLib/SpaPrivileged/src/com/android/settingslib/spaprivileged/template/app/AppListPage.kt11
-rw-r--r--packages/SettingsLib/SpaPrivileged/tests/src/com/android/settingslib/spaprivileged/template/app/AppListPageTest.kt34
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"
}