Loading packages/SettingsLib/SpaPrivileged/src/com/android/settingslib/spaprivileged/template/app/AppListPage.kt +8 −3 Original line number Diff line number Diff line Loading @@ -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 Loading @@ -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, Loading @@ -49,10 +52,12 @@ fun <T : AppRecord> AppListPage( SearchScaffold( title = title, actions = { if (!noMoreOptions) { MoreOptionsAction { ShowSystemAction(showSystem.value) { showSystem.value = it } moreOptions() } } }, ) { bottomPadding, searchQuery -> UserProfilePager(primaryUserOnly) { userGroup -> Loading packages/SettingsLib/SpaPrivileged/tests/src/com/android/settingslib/spaprivileged/template/app/AppListPageTest.kt +25 −9 Original line number Diff line number Diff line Loading @@ -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 Loading @@ -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) Loading @@ -96,6 +106,7 @@ class AppListPageTest { AppListPage( title = TITLE, listModel = TestAppListModel(), noMoreOptions = noMoreOptions, header = header, appList = { appListState.value = this }, ) Loading @@ -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" } Loading Loading
packages/SettingsLib/SpaPrivileged/src/com/android/settingslib/spaprivileged/template/app/AppListPage.kt +8 −3 Original line number Diff line number Diff line Loading @@ -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 Loading @@ -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, Loading @@ -49,10 +52,12 @@ fun <T : AppRecord> AppListPage( SearchScaffold( title = title, actions = { if (!noMoreOptions) { MoreOptionsAction { ShowSystemAction(showSystem.value) { showSystem.value = it } moreOptions() } } }, ) { bottomPadding, searchQuery -> UserProfilePager(primaryUserOnly) { userGroup -> Loading
packages/SettingsLib/SpaPrivileged/tests/src/com/android/settingslib/spaprivileged/template/app/AppListPageTest.kt +25 −9 Original line number Diff line number Diff line Loading @@ -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 Loading @@ -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) Loading @@ -96,6 +106,7 @@ class AppListPageTest { AppListPage( title = TITLE, listModel = TestAppListModel(), noMoreOptions = noMoreOptions, header = header, appList = { appListState.value = this }, ) Loading @@ -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" } Loading