use of com.android.server.location.LocationRequestStatistics.PackageStatistics in project android_frameworks_base by ResurrectionRemix.
the class LocationRequestStatisticsTest method testSinglePackage_stopAndRestart.
/**
* Tests that adding a single package works correctly when it is stopped and restarted.
*/
public void testSinglePackage_stopAndRestart() {
mStatistics.startRequesting(PACKAGE1, PROVIDER1, INTERVAL1);
mStatistics.stopRequesting(PACKAGE1, PROVIDER1);
mStatistics.startRequesting(PACKAGE1, PROVIDER1, INTERVAL1);
assertEquals(1, mStatistics.statistics.size());
PackageProviderKey key = mStatistics.statistics.keySet().iterator().next();
assertEquals(PACKAGE1, key.packageName);
assertEquals(PROVIDER1, key.providerName);
PackageStatistics stats = mStatistics.statistics.values().iterator().next();
verifyStatisticsTimes(stats);
assertEquals(INTERVAL1, stats.getFastestIntervalMs());
assertEquals(INTERVAL1, stats.getSlowestIntervalMs());
assertTrue(stats.isActive());
mStatistics.stopRequesting(PACKAGE1, PROVIDER1);
assertFalse(stats.isActive());
}
use of com.android.server.location.LocationRequestStatistics.PackageStatistics in project android_frameworks_base by ResurrectionRemix.
the class LocationRequestStatisticsTest method testMultiplePackages.
/**
* Tests that adding multiple packages works correctly.
*/
public void testMultiplePackages() {
mStatistics.startRequesting(PACKAGE1, PROVIDER1, INTERVAL1);
mStatistics.startRequesting(PACKAGE1, PROVIDER2, INTERVAL1);
mStatistics.startRequesting(PACKAGE1, PROVIDER2, INTERVAL2);
mStatistics.startRequesting(PACKAGE2, PROVIDER1, INTERVAL1);
assertEquals(3, mStatistics.statistics.size());
PackageProviderKey key1 = new PackageProviderKey(PACKAGE1, PROVIDER1);
PackageStatistics stats1 = mStatistics.statistics.get(key1);
verifyStatisticsTimes(stats1);
assertEquals(INTERVAL1, stats1.getSlowestIntervalMs());
assertEquals(INTERVAL1, stats1.getFastestIntervalMs());
assertTrue(stats1.isActive());
PackageProviderKey key2 = new PackageProviderKey(PACKAGE1, PROVIDER2);
PackageStatistics stats2 = mStatistics.statistics.get(key2);
verifyStatisticsTimes(stats2);
assertEquals(INTERVAL2, stats2.getSlowestIntervalMs());
assertEquals(INTERVAL1, stats2.getFastestIntervalMs());
assertTrue(stats2.isActive());
PackageProviderKey key3 = new PackageProviderKey(PACKAGE2, PROVIDER1);
PackageStatistics stats3 = mStatistics.statistics.get(key3);
verifyStatisticsTimes(stats3);
assertEquals(INTERVAL1, stats3.getSlowestIntervalMs());
assertEquals(INTERVAL1, stats3.getFastestIntervalMs());
assertTrue(stats3.isActive());
mStatistics.stopRequesting(PACKAGE1, PROVIDER1);
assertFalse(stats1.isActive());
assertTrue(stats2.isActive());
assertTrue(stats3.isActive());
mStatistics.stopRequesting(PACKAGE1, PROVIDER2);
assertFalse(stats1.isActive());
assertTrue(stats2.isActive());
assertTrue(stats3.isActive());
mStatistics.stopRequesting(PACKAGE1, PROVIDER2);
assertFalse(stats2.isActive());
mStatistics.stopRequesting(PACKAGE2, PROVIDER1);
assertFalse(stats1.isActive());
assertFalse(stats2.isActive());
assertFalse(stats3.isActive());
}
use of com.android.server.location.LocationRequestStatistics.PackageStatistics in project android_frameworks_base by DirtyUnicorns.
the class LocationRequestStatisticsTest method testSinglePackage.
/**
* Tests that adding a single package works correctly.
*/
public void testSinglePackage() {
mStatistics.startRequesting(PACKAGE1, PROVIDER1, INTERVAL1);
assertEquals(1, mStatistics.statistics.size());
PackageProviderKey key = mStatistics.statistics.keySet().iterator().next();
assertEquals(PACKAGE1, key.packageName);
assertEquals(PROVIDER1, key.providerName);
PackageStatistics stats = mStatistics.statistics.values().iterator().next();
verifyStatisticsTimes(stats);
assertEquals(INTERVAL1, stats.getFastestIntervalMs());
assertEquals(INTERVAL1, stats.getSlowestIntervalMs());
assertTrue(stats.isActive());
}
use of com.android.server.location.LocationRequestStatistics.PackageStatistics in project android_frameworks_base by DirtyUnicorns.
the class LocationRequestStatisticsTest method testMultiplePackages.
/**
* Tests that adding multiple packages works correctly.
*/
public void testMultiplePackages() {
mStatistics.startRequesting(PACKAGE1, PROVIDER1, INTERVAL1);
mStatistics.startRequesting(PACKAGE1, PROVIDER2, INTERVAL1);
mStatistics.startRequesting(PACKAGE1, PROVIDER2, INTERVAL2);
mStatistics.startRequesting(PACKAGE2, PROVIDER1, INTERVAL1);
assertEquals(3, mStatistics.statistics.size());
PackageProviderKey key1 = new PackageProviderKey(PACKAGE1, PROVIDER1);
PackageStatistics stats1 = mStatistics.statistics.get(key1);
verifyStatisticsTimes(stats1);
assertEquals(INTERVAL1, stats1.getSlowestIntervalMs());
assertEquals(INTERVAL1, stats1.getFastestIntervalMs());
assertTrue(stats1.isActive());
PackageProviderKey key2 = new PackageProviderKey(PACKAGE1, PROVIDER2);
PackageStatistics stats2 = mStatistics.statistics.get(key2);
verifyStatisticsTimes(stats2);
assertEquals(INTERVAL2, stats2.getSlowestIntervalMs());
assertEquals(INTERVAL1, stats2.getFastestIntervalMs());
assertTrue(stats2.isActive());
PackageProviderKey key3 = new PackageProviderKey(PACKAGE2, PROVIDER1);
PackageStatistics stats3 = mStatistics.statistics.get(key3);
verifyStatisticsTimes(stats3);
assertEquals(INTERVAL1, stats3.getSlowestIntervalMs());
assertEquals(INTERVAL1, stats3.getFastestIntervalMs());
assertTrue(stats3.isActive());
mStatistics.stopRequesting(PACKAGE1, PROVIDER1);
assertFalse(stats1.isActive());
assertTrue(stats2.isActive());
assertTrue(stats3.isActive());
mStatistics.stopRequesting(PACKAGE1, PROVIDER2);
assertFalse(stats1.isActive());
assertTrue(stats2.isActive());
assertTrue(stats3.isActive());
mStatistics.stopRequesting(PACKAGE1, PROVIDER2);
assertFalse(stats2.isActive());
mStatistics.stopRequesting(PACKAGE2, PROVIDER1);
assertFalse(stats1.isActive());
assertFalse(stats2.isActive());
assertFalse(stats3.isActive());
}
use of com.android.server.location.LocationRequestStatistics.PackageStatistics in project android_frameworks_base by DirtyUnicorns.
the class LocationRequestStatisticsTest method testSinglePackage_stopAndRestart.
/**
* Tests that adding a single package works correctly when it is stopped and restarted.
*/
public void testSinglePackage_stopAndRestart() {
mStatistics.startRequesting(PACKAGE1, PROVIDER1, INTERVAL1);
mStatistics.stopRequesting(PACKAGE1, PROVIDER1);
mStatistics.startRequesting(PACKAGE1, PROVIDER1, INTERVAL1);
assertEquals(1, mStatistics.statistics.size());
PackageProviderKey key = mStatistics.statistics.keySet().iterator().next();
assertEquals(PACKAGE1, key.packageName);
assertEquals(PROVIDER1, key.providerName);
PackageStatistics stats = mStatistics.statistics.values().iterator().next();
verifyStatisticsTimes(stats);
assertEquals(INTERVAL1, stats.getFastestIntervalMs());
assertEquals(INTERVAL1, stats.getSlowestIntervalMs());
assertTrue(stats.isActive());
mStatistics.stopRequesting(PACKAGE1, PROVIDER1);
assertFalse(stats.isActive());
}
Aggregations