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

Commit 9f6351b5 authored by Julia Reynolds's avatar Julia Reynolds Committed by Android (Google) Code Review
Browse files

Merge "Stop controller from steal preference clicks" into rvc-dev

parents a4c7cb1e bc0c7a62
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -62,7 +62,7 @@ public class ConversationPromotePreferenceController extends NotificationPrefere

    @Override
    public boolean handlePreferenceTreeClick(Preference preference) {
        if (mChannel == null) {
        if (mChannel == null || !KEY.equals(preference.getKey())) {
            return false;
        }
        mChannel.setDemoted(false);
+18 −0
Original line number Diff line number Diff line
@@ -20,9 +20,11 @@ import static android.app.NotificationManager.IMPORTANCE_DEFAULT;

import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
import static org.mockito.ArgumentMatchers.any;
import static org.mockito.ArgumentMatchers.anyInt;
import static org.mockito.ArgumentMatchers.eq;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.never;
import static org.mockito.Mockito.spy;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
@@ -122,4 +124,20 @@ public class ConversationPromotePreferenceControllerTest {

        verify(mFragment).getActivity();
    }

    @Test
    public void testHandlePreferenceClick_wrongKey() {
        NotificationBackend.AppRow appRow = new NotificationBackend.AppRow();
        NotificationChannel channel = new NotificationChannel("", "", IMPORTANCE_DEFAULT);
        channel.setConversationId("a", "a");
        channel.setDemoted(true);
        mController.onResume(appRow, channel, null, null, null, null);

        Preference pref = mock(Preference.class);
        when(pref.getKey()).thenReturn("wrong");
        assertFalse(mController.handlePreferenceTreeClick(pref));

        verify(mBackend, never()).updateChannel(eq(null), anyInt(), any());
        verify(mFragment, never()).getActivity();
    }
}