### Question:
SettingsSelectWifiNetworkPresenter extends BaseSelectWifiNetworkPresenter { @Override public boolean onBackPressed(@NonNull final Runnable ignored) { if (shouldUseDefaultBackPressedBehavior()) { execute(() -> view.cancelFlow()); } return true; } SettingsSelectWifiNetworkPresenter(final HardwareInteractor hardwareInteractor,
                                              final boolean shouldUseToolbar); @Override boolean onBackPressed(@NonNull final Runnable ignored); @Override String getOnCreateAnalyticsEvent(); @Override String getOnScanAnalyticsEvent(); @Override String getOnRescanAnalyticsEvent();  }### Answer:
@Test public void onBackPressedWithViewAndScanning() throws Exception { final Runnable mockRunnable = mock(Runnable.class); final Output mockOutput = getMockOutput(true); presenter.setView(mockOutput); final boolean intercepted = presenter.onBackPressed(mockRunnable); assertThat(intercepted, equalTo(true)); verify(mockOutput, times(0)).cancelFlow(); verify(mockRunnable, times(0)).run(); }
@Test public void onBackPressed() throws Exception { final Runnable mockRunnable = mock(Runnable.class); final Output mockOutput = getMockOutput(false); presenter.setView(mockOutput); final boolean intercepted = presenter.onBackPressed(mockRunnable); assertThat(intercepted, equalTo(true)); verify(mockOutput, times(1)).cancelFlow(); verify(mockRunnable, times(0)).run(); }