use of android.content.rollback.PackageRollbackInfo in project robolectric by robolectric.
the class PackageRollbackInfoBuilderTest method build_onR.
@Test
@Config(sdk = Build.VERSION_CODES.R)
public void build_onR() {
PackageRollbackInfo packageRollbackInfo = PackageRollbackInfoBuilder.newBuilder().setPackageRolledBackFrom(packageRolledBackFrom).setPackageRolledBackTo(packageRolledBackTo).addPendingBackup(BACKUP_ID).addPendingRestore(RESTORE_INFO_USER_ID, RESTORE_INFO_APP_ID, RESTORE_INFO_SEINFO).setIsApex(true).setIsApkInApex(true).addSnapshottedUser(SNAPSHOTTED_USER_ID).setCeSnapshotInodes(ceSnapshotInodes).build();
assertThat(packageRollbackInfo).isNotNull();
assertThat(packageRollbackInfo.getVersionRolledBackFrom()).isEqualTo(packageRolledBackFrom);
assertThat(packageRollbackInfo.getVersionRolledBackTo()).isEqualTo(packageRolledBackTo);
int[] pendingBackups = ((IntArray) ReflectionHelpers.callInstanceMethod(packageRollbackInfo, "getPendingBackups")).toArray();
assertThat(pendingBackups).asList().containsExactly(BACKUP_ID);
assertThat(packageRollbackInfo.getPendingRestores()).hasSize(1);
assertThat(packageRollbackInfo.getPendingRestores().get(0).userId).isEqualTo(RESTORE_INFO_USER_ID);
assertThat(packageRollbackInfo.getPendingRestores().get(0).appId).isEqualTo(RESTORE_INFO_APP_ID);
assertThat(packageRollbackInfo.getPendingRestores().get(0).seInfo).isEqualTo(RESTORE_INFO_SEINFO);
assertThat(packageRollbackInfo.isApex()).isTrue();
assertThat(packageRollbackInfo.isApkInApex()).isTrue();
int[] snapshottedUsers = ((IntArray) ReflectionHelpers.callInstanceMethod(packageRollbackInfo, "getSnapshottedUsers")).toArray();
assertThat(snapshottedUsers).asList().containsExactly(SNAPSHOTTED_USER_ID);
assertThat((SparseLongArray) ReflectionHelpers.callInstanceMethod(packageRollbackInfo, "getCeSnapshotInodes")).isEqualTo(ceSnapshotInodes);
}
use of android.content.rollback.PackageRollbackInfo in project robolectric by robolectric.
the class PackageRollbackInfoBuilderTest method build_withBasicFields.
@Test
public void build_withBasicFields() {
PackageRollbackInfo packageRollbackInfo = PackageRollbackInfoBuilder.newBuilder().setPackageRolledBackFrom(packageRolledBackFrom).setPackageRolledBackTo(packageRolledBackTo).build();
assertThat(packageRollbackInfo).isNotNull();
assertThat(packageRollbackInfo.getVersionRolledBackFrom()).isEqualTo(packageRolledBackFrom);
assertThat(packageRollbackInfo.getVersionRolledBackTo()).isEqualTo(packageRolledBackTo);
}
use of android.content.rollback.PackageRollbackInfo in project robolectric by robolectric.
the class PackageRollbackInfoBuilderTest method build_onQ.
@Test
@Config(sdk = Build.VERSION_CODES.Q)
public void build_onQ() {
PackageRollbackInfo packageRollbackInfo = PackageRollbackInfoBuilder.newBuilder().setPackageRolledBackFrom(packageRolledBackFrom).setPackageRolledBackTo(packageRolledBackTo).addPendingBackup(BACKUP_ID).addPendingRestore(RESTORE_INFO_USER_ID, RESTORE_INFO_APP_ID, RESTORE_INFO_SEINFO).setIsApex(true).addInstalledUser(INSTALLED_USER_ID).setCeSnapshotInodes(ceSnapshotInodes).build();
assertThat(packageRollbackInfo).isNotNull();
assertThat(packageRollbackInfo.getVersionRolledBackFrom()).isEqualTo(packageRolledBackFrom);
assertThat(packageRollbackInfo.getVersionRolledBackTo()).isEqualTo(packageRolledBackTo);
int[] pendingBackups = ((IntArray) ReflectionHelpers.callInstanceMethod(packageRollbackInfo, "getPendingBackups")).toArray();
assertThat(pendingBackups).asList().containsExactly(BACKUP_ID);
assertThat(packageRollbackInfo.getPendingRestores()).hasSize(1);
assertThat(packageRollbackInfo.getPendingRestores().get(0).userId).isEqualTo(RESTORE_INFO_USER_ID);
assertThat(packageRollbackInfo.getPendingRestores().get(0).appId).isEqualTo(RESTORE_INFO_APP_ID);
assertThat(packageRollbackInfo.getPendingRestores().get(0).seInfo).isEqualTo(RESTORE_INFO_SEINFO);
assertThat(packageRollbackInfo.isApex()).isTrue();
IntArray installedUsers = ReflectionHelpers.callInstanceMethod(packageRollbackInfo, "getInstalledUsers");
assertThat(installedUsers.toArray()).hasLength(1);
assertThat(installedUsers.get(0)).isEqualTo(INSTALLED_USER_ID);
if (RuntimeEnvironment.getApiLevel() <= Build.VERSION_CODES.R) {
assertThat((SparseLongArray) ReflectionHelpers.callInstanceMethod(packageRollbackInfo, "getCeSnapshotInodes")).isEqualTo(ceSnapshotInodes);
}
}
use of android.content.rollback.PackageRollbackInfo in project robolectric by robolectric.
the class RollbackInfoBuilderTest method build.
@Test
public void build() {
VersionedPackage packageRolledBackFrom = new VersionedPackage("test_package", 123);
VersionedPackage packageRolledBackTo = new VersionedPackage("test_package", 345);
PackageRollbackInfo packageRollbackInfo = PackageRollbackInfoBuilder.newBuilder().setPackageRolledBackFrom(packageRolledBackFrom).setPackageRolledBackTo(packageRolledBackTo).build();
RollbackInfo rollbackInfo = RollbackInfoBuilder.newBuilder().setRollbackId(1).setPackages(ImmutableList.of(packageRollbackInfo)).setIsStaged(true).setCausePackages(ImmutableList.of(packageRolledBackFrom)).setCommittedSessionId(10).build();
assertThat(rollbackInfo).isNotNull();
assertThat(rollbackInfo.getRollbackId()).isEqualTo(1);
assertThat(rollbackInfo.getPackages()).containsExactly(packageRollbackInfo);
assertThat(rollbackInfo.isStaged()).isTrue();
assertThat(rollbackInfo.getCausePackages()).containsExactly(packageRolledBackFrom);
assertThat(rollbackInfo.getCommittedSessionId()).isEqualTo(10);
}
Aggregations