@Test public void testFingerprintHistogram() { wifiCapturer.makeFingerprint(progressDialog, consumer); receiver = getReceiver(); when(progressDialog.getProgress()).thenReturn(1, 2, 100); List<ScanResult> scanResult1 = makeScanResult(scan1, -50); List<ScanResult> scanResult2 = makeScanResult(scan2, -40); List<ScanResult> scanResult3 = makeScanResult(scan3, -50); when(wifiManager.getScanResults()).thenReturn(scanResult1, scanResult2, scanResult3); receiver.onReceive(null, null); receiver.onReceive(null, null); receiver.onReceive(null, null); ArgumentCaptor<Runnable> uiRunnableArgumentCaptor = ArgumentCaptor.forClass(Runnable.class); Runnable uiRunnable; verify(activity, times(3)).runOnUiThread(uiRunnableArgumentCaptor.capture()); uiRunnable = uiRunnableArgumentCaptor.getAllValues().get(0); uiRunnable.run(); uiRunnable = uiRunnableArgumentCaptor.getAllValues().get(1); uiRunnable.run(); uiRunnable = uiRunnableArgumentCaptor.getAllValues().get(2); uiRunnable.run(); ArgumentCaptor<Histogram> consumerArgumentCaptor = ArgumentCaptor.forClass(Histogram.class); verify(consumer).addHistogram(consumerArgumentCaptor.capture()); Histogram histogram = consumerArgumentCaptor.getValue(); assertEquals(1, histogram.size()); assertTrue(histogram.keySet().contains("00:01:02:03:04:05")); Map<Integer, Float> levels = histogram.get("00:01:02:03:04:05"); assertEquals(2, levels.size()); assertEquals(1.0 / 3.0, levels.get(-40), 0.00001); assertEquals(2.0 / 3.0, levels.get(-50), 0.00001); }
public void makeFingerprint(final ProgressDialog progressDialog, final HistogramConsumer consumer) { this.progressDialog = progressDialog; this.fingerprintHistogramConsumer = consumer; startSensors(); }
WifiCapturer implements SensorCollector { public void makeFingerprint(final ProgressDialog progressDialog, final HistogramConsumer consumer) { this.progressDialog = progressDialog; this.fingerprintHistogramConsumer = consumer; startSensors(); } }
WifiCapturer implements SensorCollector { public void makeFingerprint(final ProgressDialog progressDialog, final HistogramConsumer consumer) { this.progressDialog = progressDialog; this.fingerprintHistogramConsumer = consumer; startSensors(); } WifiCapturer(final Activity activity);  WifiCapturer(final Activity activity, final HistogramConsumer consumer, final int maxAge); }
WifiCapturer implements SensorCollector { public void makeFingerprint(final ProgressDialog progressDialog, final HistogramConsumer consumer) { this.progressDialog = progressDialog; this.fingerprintHistogramConsumer = consumer; startSensors(); } WifiCapturer(final Activity activity);  WifiCapturer(final Activity activity, final HistogramConsumer consumer, final int maxAge); void makeFingerprint(final  ProgressDialog progressDialog, final HistogramConsumer consumer); @Override void startSensors(); @Override void stopSensors(); }
WifiCapturer implements SensorCollector { public void makeFingerprint(final ProgressDialog progressDialog, final HistogramConsumer consumer) { this.progressDialog = progressDialog; this.fingerprintHistogramConsumer = consumer; startSensors(); } WifiCapturer(final Activity activity);  WifiCapturer(final Activity activity, final HistogramConsumer consumer, final int maxAge); void makeFingerprint(final  ProgressDialog progressDialog, final HistogramConsumer consumer); @Override void startSensors(); @Override void stopSensors(); static final String TAG; static final int NUMBER_SCANS; }