Loading src/com/android/settings/notification/app/ConversationPromotePreferenceController.java +1 −1 Original line number Diff line number Diff line Loading @@ -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); Loading tests/robotests/src/com/android/settings/notification/app/ConversationPromotePreferenceControllerTest.java +18 −0 Original line number Diff line number Diff line Loading @@ -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; Loading Loading @@ -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(); } } Loading
src/com/android/settings/notification/app/ConversationPromotePreferenceController.java +1 −1 Original line number Diff line number Diff line Loading @@ -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); Loading
tests/robotests/src/com/android/settings/notification/app/ConversationPromotePreferenceControllerTest.java +18 −0 Original line number Diff line number Diff line Loading @@ -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; Loading Loading @@ -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(); } }