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

Commit c4f56147 authored by Anton Potapov's avatar Anton Potapov Committed by Automerger Merge Worker
Browse files

Merge "Add app removal dialog button check" into udc-dev am: 244087bf

parents 6479cf5c 244087bf
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")