Search in sources :

Example 1 with PackageRollbackInfo

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);
}
Also used : IntArray(android.util.IntArray) PackageRollbackInfo(android.content.rollback.PackageRollbackInfo) SparseLongArray(android.util.SparseLongArray) Test(org.junit.Test) Config(org.robolectric.annotation.Config)

Example 2 with PackageRollbackInfo

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);
}
Also used : PackageRollbackInfo(android.content.rollback.PackageRollbackInfo) Test(org.junit.Test)

Example 3 with PackageRollbackInfo

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);
    }
}
Also used : IntArray(android.util.IntArray) PackageRollbackInfo(android.content.rollback.PackageRollbackInfo) SparseLongArray(android.util.SparseLongArray) Test(org.junit.Test) Config(org.robolectric.annotation.Config)

Example 4 with PackageRollbackInfo

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);
}
Also used : RollbackInfo(android.content.rollback.RollbackInfo) PackageRollbackInfo(android.content.rollback.PackageRollbackInfo) VersionedPackage(android.content.pm.VersionedPackage) PackageRollbackInfo(android.content.rollback.PackageRollbackInfo) Test(org.junit.Test)

Aggregations

PackageRollbackInfo (android.content.rollback.PackageRollbackInfo)4 Test (org.junit.Test)4 IntArray (android.util.IntArray)2 SparseLongArray (android.util.SparseLongArray)2 Config (org.robolectric.annotation.Config)2 VersionedPackage (android.content.pm.VersionedPackage)1 RollbackInfo (android.content.rollback.RollbackInfo)1