use of android.content.pm.PackageStats in project robolectric by robolectric.
the class ShadowPackageManager method addPackageNoDefaults.
/**
* Adds a package to the {@link PackageManager}, but doesn't set any default values on it.
*
* Right now it will not set {@link ApplicationInfo#FLAG_INSTALLED} flag on its application, so
* if not set explicitly, it will be treated as not installed.
*/
public void addPackageNoDefaults(PackageInfo packageInfo) {
PackageStats packageStats = new PackageStats(packageInfo.packageName);
addPackage(packageInfo, packageStats);
}
use of android.content.pm.PackageStats in project robolectric by robolectric.
the class ShadowPackageManagerTest method whenPreconfiguredForAnotherPackage_getPackageSizeInfo_callsBackWithConfiguredValues.
@Test
// Functionality removed in O
@Config(minSdk = N, maxSdk = N_MR1)
public void whenPreconfiguredForAnotherPackage_getPackageSizeInfo_callsBackWithConfiguredValues() throws Exception {
PackageInfo packageInfo = new PackageInfo();
packageInfo.packageName = "org.other";
PackageStats packageStats = new PackageStats("org.other");
shadowOf(packageManager).addPackage(packageInfo, packageStats);
IPackageStatsObserver packageStatsObserver = mock(IPackageStatsObserver.class);
packageManager.getPackageSizeInfo("org.other", packageStatsObserver);
shadowMainLooper().idle();
verify(packageStatsObserver).onGetStatsCompleted(packageStatsCaptor.capture(), eq(true));
assertThat(packageStatsCaptor.getValue().packageName).isEqualTo("org.other");
assertThat(packageStatsCaptor.getValue().toString()).isEqualTo(packageStats.toString());
}
use of android.content.pm.PackageStats in project robolectric by robolectric.
the class ShadowPackageManagerTest method whenPreconfigured_getPackageSizeInfo_callsBackWithConfiguredValues.
@Test
// Functionality removed in O
@Config(minSdk = N, maxSdk = N_MR1)
public void whenPreconfigured_getPackageSizeInfo_callsBackWithConfiguredValues() throws Exception {
PackageInfo packageInfo = new PackageInfo();
packageInfo.packageName = "org.robolectric";
PackageStats packageStats = new PackageStats("org.robolectric");
shadowOf(packageManager).addPackage(packageInfo, packageStats);
IPackageStatsObserver packageStatsObserver = mock(IPackageStatsObserver.class);
packageManager.getPackageSizeInfo("org.robolectric", packageStatsObserver);
shadowMainLooper().idle();
verify(packageStatsObserver).onGetStatsCompleted(packageStatsCaptor.capture(), eq(true));
assertThat(packageStatsCaptor.getValue().packageName).isEqualTo("org.robolectric");
assertThat(packageStatsCaptor.getValue().toString()).isEqualTo(packageStats.toString());
}
Aggregations