MapActivity extends AbstractMapActivity implements DownloadListener<Map<String, Collection>> { @Override protected void onResume() { super.onResume(); applySettings(); }  @Override void onCreate(final Bundle savedInstanceState); @Override boolean onCreateOptionsMenu(final Menu menu); @Override void onDownloadFinished(final DownloadTask task, final boolean success, final Map<String, Collection> data); @Override // NOSONAR - Method cannot be shortened!!! boolean onOptionsItemSelected(final MenuItem item); void toggleFingerprintMode(final View view);  }
@Test public void testSettings_MapMatching_ON_OFF() { String prefMapMatchingToggle = resources.getString(R.string.key_pref_mapMatching_toggle); sharedPreferences.edit().putBoolean(prefMapMatchingToggle, true).commit(); activity.onResume(); verify(userLocator, times(1)).setMapMatchingMode(eq(UserLocator.MAP_MATCHING_MODE_SIMPLE_WAY_SNAP)); verify(userLocator, never()).setMapMatchingMode(eq(UserLocator.MAP_MATCHING_MODE_NONE)); sharedPreferences.edit().putBoolean(prefMapMatchingToggle, false).commit(); activity.onResume(); verify(userLocator, times(1)).setMapMatchingMode(eq(UserLocator.MAP_MATCHING_MODE_NONE)); }
@Test public void testSettings_WayOverlay_ON_OFF() { String prefShowWayOverlay = resources.getString(R.string.key_pref_mapMatching_showWayOverlay); sharedPreferences.edit().putBoolean(prefShowWayOverlay, true).commit(); activity.onResume(); assertTrue(activity.getMapView().getOverlays().contains(activity.wayOverlay)); sharedPreferences.edit().putBoolean(prefShowWayOverlay, false).commit(); activity.onResume(); assertFalse(activity.getMapView().getOverlays().contains(activity.wayOverlay)); }
@Test public void testSettings_OutlierDetection_ON_Default_CME2() { String prefOutlierKey = resources.getString(R.string.key_pref_outlierEnabled); sharedPreferences.edit().putBoolean(prefOutlierKey, true).commit(); activity.onResume(); verify(userLocator, times(1)).setOutlierMode(eq(UserLocator.OUTLIER_MODE_CME)); verify(userLocator, never()).setOutlierMode(eq(UserLocator.OUTLIER_MODE_PLASMONA)); verify(userLocator, never()).setOutlierMode(eq(UserLocator.OUTLIER_MODE_NO_DETECTION)); }
@Test public void testSettings_OutlierDetection_ON_Plasmona() { String prefOutlierKey = resources.getString(R.string.key_pref_outlierEnabled); sharedPreferences.edit().putBoolean(prefOutlierKey, true).commit(); String outlierListKey = resources.getString(R.string.key_pref_outlierAlgorithmList); String plasmonaAlgKey = resources.getString(R.string.outlierAlgorithmPlasmona); sharedPreferences.edit().putString(outlierListKey, plasmonaAlgKey).commit(); activity.onResume(); verify(userLocator, times(1)).setOutlierMode(eq(UserLocator.OUTLIER_MODE_PLASMONA)); verify(userLocator, never()).setOutlierMode(eq(UserLocator.OUTLIER_MODE_CME)); verify(userLocator, never()).setOutlierMode(eq(UserLocator.OUTLIER_MODE_NO_DETECTION)); }
@Test public void testSettings_OutlierDetection_OFF() { activity.onResume(); verify(userLocator, times(1)).setOutlierMode(eq(UserLocator.OUTLIER_MODE_NO_DETECTION)); verify(userLocator, never()).setOutlierMode(eq(UserLocator.OUTLIER_MODE_CME)); verify(userLocator, never()).setOutlierMode(eq(UserLocator.OUTLIER_MODE_PLASMONA)); }
@Test public void testSettings_StatisticFilter_ON_Default_Median() { String prefFilterKey = resources.getString(R.string.key_pref_filteringEnabled); sharedPreferences.edit().putBoolean(prefFilterKey, true).commit(); activity.onResume(); verify(userLocator, times(1)).setStatisticFilterMode(eq(UserLocator.STATISTIC_FILTER_MODE_MEDIAN)); verify(userLocator, never()).setStatisticFilterMode(eq(UserLocator.STATISTIC_FILTER_MODE_AVERAGE)); verify(userLocator, never()).setStatisticFilterMode(eq(UserLocator.STATISTIC_FILTER_MODE_NO_FILTER)); }
@Test public void testSettings_StatisticFilter_ON_Average() { String prefFilterKey = resources.getString(R.string.key_pref_filteringEnabled); sharedPreferences.edit().putBoolean(prefFilterKey, true).commit(); String filterListKey = resources.getString(R.string.key_pref_filterAlgorithmList); String averageKey = resources.getString(R.string.filterAlgorithmAverage); sharedPreferences.edit().putString(filterListKey, averageKey).commit(); activity.onResume(); verify(userLocator, times(1)).setStatisticFilterMode(eq(UserLocator.STATISTIC_FILTER_MODE_AVERAGE)); verify(userLocator, never()).setStatisticFilterMode(eq(UserLocator.STATISTIC_FILTER_MODE_MEDIAN)); verify(userLocator, never()).setStatisticFilterMode(eq(UserLocator.STATISTIC_FILTER_MODE_NO_FILTER)); }
@Test public void testSettings_StatisticFilter_OFF() { activity.onResume(); verify(userLocator, times(1)).setStatisticFilterMode(eq(UserLocator.STATISTIC_FILTER_MODE_NO_FILTER)); verify(userLocator, never()).setStatisticFilterMode(eq(UserLocator.STATISTIC_FILTER_MODE_AVERAGE)); verify(userLocator, never()).setStatisticFilterMode(eq(UserLocator.STATISTIC_FILTER_MODE_MEDIAN)); }
@Test public void testSettings_LowPassFilter_ON() { String prefLowPassFilterKey = resources.getString(R.string.key_pref_deadReckoning_lowPassToggle); sharedPreferences.edit().putBoolean(prefLowPassFilterKey, true).commit(); activity.onResume(); verify(userLocator, times(1)).setCompassFilterEnabled(eq(true)); verify(userLocator, never()).setCompassFilterEnabled(eq(false)); }
@Test public void testSettings_LowPassFilter_OFF() { activity.onResume(); verify(userLocator, times(1)).setCompassFilterEnabled(eq(false)); verify(userLocator, never()).setCompassFilterEnabled(eq(true)); }
@Test public void testSettings_ShowParticles_ON() { String prefShowParticlesKey = resources.getString(R.string.key_pref_showparticles); sharedPreferences.edit().putBoolean(prefShowParticlesKey, true).commit(); activity.onResume(); verify(userLocator.getParticleFilter(), times(1)).setShowParticles(eq(true)); verify(userLocator.getParticleFilter(), never()).setShowParticles(eq(false)); }
@Test public void testSettings_ShowParticles_OFF() { activity.onResume(); verify(userLocator.getParticleFilter(), times(1)).setShowParticles(eq(false)); verify(userLocator.getParticleFilter(), never()).setShowParticles(eq(true)); }