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

Commit 17c54fbc authored by Anton Potapov's avatar Anton Potapov
Browse files

Add app removal dialog button check

Test: added autotest
Bug: 265180342
Change-Id: I1ad97553125561454fa34d45ec4809085d2ca64a
parent b755b28b
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")