Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit ceba00a7 authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Android (Google) Code Review
Browse files

Merge "Add test for rollback of same version apk." into qt-dev

parents c37d8321 e846376e
Loading
Loading
Loading
Loading
+35 −0
Original line number Diff line number Diff line
@@ -39,6 +39,7 @@ import android.util.Log;

import androidx.test.InstrumentationRegistry;

import org.junit.Ignore;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.JUnit4;
@@ -774,6 +775,40 @@ public class RollbackTest {
        }
    }

    @Test
    @Ignore("b/120200473")
    /**
     * Test rollback when app is updated to its same version.
     */
    public void testSameVersionUpdate() throws Exception {
        try {
            RollbackTestUtils.adoptShellPermissionIdentity(
                    Manifest.permission.INSTALL_PACKAGES,
                    Manifest.permission.DELETE_PACKAGES,
                    Manifest.permission.TEST_MANAGE_ROLLBACKS);
            RollbackManager rm = RollbackTestUtils.getRollbackManager();

            RollbackTestUtils.uninstall(TEST_APP_A);
            RollbackTestUtils.install("RollbackTestAppAv1.apk", false);
            RollbackTestUtils.install("RollbackTestAppAv2.apk", true);
            RollbackTestUtils.install("RollbackTestAppACrashingV2.apk", true);
            assertEquals(2, RollbackTestUtils.getInstalledVersion(TEST_APP_A));

            RollbackInfo rollback = getUniqueRollbackInfoForPackage(
                    rm.getAvailableRollbacks(), TEST_APP_A);
            assertRollbackInfoEquals(TEST_APP_A, 2, 2, rollback);

            RollbackTestUtils.rollback(rollback.getRollbackId());
            assertEquals(2, RollbackTestUtils.getInstalledVersion(TEST_APP_A));

            rollback = getUniqueRollbackInfoForPackage(
                    rm.getRecentlyCommittedRollbacks(), TEST_APP_A);
            assertRollbackInfoEquals(TEST_APP_A, 2, 2, rollback);
        } finally {
            RollbackTestUtils.dropShellPermissionIdentity();
        }
    }

    /**
     * Test bad update automatic rollback.
     */