### Question:
LocationUtils { public static boolean isBetterLocation(final Location currentLocation, final Location newLocation) { if (newLocation == null) { return false; } if (currentLocation == null) { return true; } final long timeDelta = newLocation.getTime() - currentLocation.getTime(); if (timeDelta > DEFAULT_SIGNIFICANTLY_NEWER) { return true; } else if (timeDelta < DEFAULT_SIGNIFICANTLY_NEWER) { return false; } final int accuracyDelta = (int) (newLocation.getAccuracy() - currentLocation.getAccuracy()); if (accuracyDelta < 0) { return true; } else if (timeDelta > 0L && accuracyDelta <= 0L) { return true; } else if (timeDelta > 0L && accuracyDelta <= 200L && isSameProvider(newLocation.getProvider(), currentLocation.getProvider())) { return true; } return false; } private  LocationUtils(); static Location getLastKnownLocation(final Context context); static Location getLastKnownLocation(final Context context, final String...providers); static Location getLastKnownLocation(final LocationManager locationManager); static Location getLastKnownLocation(final LocationManager locationManager, final String...providers); static boolean isBetterLocation(final Location currentLocation, final Location newLocation); static boolean isSameProvider(final String provider1, final String provider2);  }### Answer:
@Test public void testIsBetterLocation() { assertFalse(LocationUtils.isBetterLocation(new Location(LocationManager.GPS_PROVIDER), null)); assertTrue(LocationUtils.isBetterLocation(null, new Location(LocationManager.GPS_PROVIDER))); final long now = System.currentTimeMillis(); assertTrue(now != 0); final Location currentLocation = new Location(LocationManager.GPS_PROVIDER); currentLocation.setLatitude(35.681382D); currentLocation.setLongitude(139.766084D); currentLocation.setAccuracy(200); currentLocation.setTime(now); Location newLocation; newLocation = new Location(currentLocation); newLocation.setTime(now + 2 * 60 * 1000L); assertTrue(LocationUtils.isBetterLocation(currentLocation, newLocation)); newLocation = new Location(currentLocation); newLocation.setTime(now + 1 * 60 * 1000L); assertFalse(LocationUtils.isBetterLocation(currentLocation, newLocation)); }