  @Test
  public void testInitialSnapshot() {

    ShadowSystemClock.setElapsedRealtime(5000);
    when(mContext.registerReceiver(
            Matchers.isNull(BroadcastReceiver.class), Matchers.any(IntentFilter.class)))
        .thenReturn(createBatteryIntent(BatteryManager.BATTERY_STATUS_CHARGING, 20, 100));
    DeviceBatteryMetrics metrics = new DeviceBatteryMetrics();
    DeviceBatteryMetricsCollector collector = new DeviceBatteryMetricsCollector(mContext);
    ShadowSystemClock.setElapsedRealtime(10000);
    collector.getSnapshot(metrics);
    verifySnapshot(metrics, 20, 0, 5000);
  }