DeadReckoning implements SensorEventListener, SensorCollector, DownloadListener<Map<String, Collection>> { public void setCompassFilterEnabled(boolean useLowPassFilter) { if (useLowPassFilter) { compassFilter.setWeight(compassFilterWeight); Log.d(TAG, "Low pass filter is enabled."); } else { compassFilter.setWeight(1f); Log.d(TAG, "Low pass filter is disabled."); } } DeadReckoning(final Activity activity); void startSensors(); void stopSensors(); @Override void onDownloadFinished(DownloadTask task, boolean success, Map<String, Collection> data); @Override void onSensorChanged(final SensorEvent event); @Override void onAccuracyChanged(final Sensor sensor, final int accuracy); NicGeoPoint getDelta(); void setCompassFilterEnabled(boolean useLowPassFilter); void setBaseAngle(final double baseAngle);  }
@Test public void testDisableCompassFilter() { deadReckoning.setCompassFilterEnabled(false); assertEquals(1f, ((CompassFilter) deadReckoning.compassBuffer.getFilter()).getWeight()); }
@Test public void testEnableCompassFilter() { deadReckoning.setCompassFilterEnabled(true); assertEquals(Robolectric.application.getResources().getInteger(R.integer.compass_low_pass_filter_weight) / 100.f, ((CompassFilter) deadReckoning.compassBuffer.getFilter()).getWeight()); }