Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 244087bf authored by Anton Potapov's avatar Anton Potapov Committed by Android (Google) Code Review
Browse files

Merge "Add app removal dialog button check" into udc-dev

parents c1dfe6f6 17c54fbc
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -327,8 +327,8 @@ class ControlsUiControllerImpl @Inject constructor (
    @VisibleForTesting
    internal fun startRemovingApp(componentName: ComponentName, appName: CharSequence) {
        removeAppDialog?.cancel()
        removeAppDialog = dialogsFactory.createRemoveAppDialog(context, appName) {
            if (!controlsController.get().removeFavorites(componentName)) {
        removeAppDialog = dialogsFactory.createRemoveAppDialog(context, appName) { shouldRemove ->
            if (!shouldRemove || !controlsController.get().removeFavorites(componentName)) {
                return@createRemoveAppDialog
            }

+22 −2
Original line number Diff line number Diff line
@@ -361,6 +361,26 @@ class ControlsUiControllerImplTest : SysuiTestCase() {
        assertThat(preferredPanelRepository.getSelectedComponent()).isNull()
    }

    @Test
    fun testCancelRemovingAppsDoesntRemoveFavorite() {
        val componentName = ComponentName(context, "cls")
        whenever(controlsController.removeFavorites(eq(componentName))).thenReturn(true)
        val panel = SelectedItem.PanelItem("App name", componentName)
        preferredPanelRepository.setSelectedComponent(
            SelectedComponentRepository.SelectedComponent(panel)
        )
        underTest.show(parent, {}, context)
        underTest.startRemovingApp(componentName, "Test App")

        fakeDialogController.clickNeutral()

        verify(controlsController, never()).removeFavorites(eq(componentName))
        assertThat(underTest.getPreferredSelectedItem(emptyList())).isEqualTo(panel)
        assertThat(preferredPanelRepository.shouldAddDefaultComponent()).isTrue()
        assertThat(preferredPanelRepository.getSelectedComponent())
            .isEqualTo(SelectedComponentRepository.SelectedComponent(panel))
    }

    @Test
    fun testHideCancelsTheRemoveAppDialog() {
        val componentName = ComponentName(context, "cls")