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

Commit 04bff126 authored by Jackal Guo's avatar Jackal Guo
Browse files

Fix broken test

Previously, flag INSTALL_ALL_USERS  would treat this as an update,
and only do it for the users who already have the app installed.
Since the behavior changes, revise the test accordingly.

Fix: 226813445
Test: atest FrameworksServicesTests:PackageManagerServiceTest#\
        testInstallReason_userRemainsUninstalled_keepUnknown
Change-Id: If9a84c401224dad238485d6728efe3eb7cad02e2
parent 617b65e4
Loading
Loading
Loading
Loading
+2 −6
Original line number Diff line number Diff line
@@ -523,15 +523,11 @@ public class PackageManagerServiceTest {
            userId = um.createUser("Test User", 0 /* flags */).getUserHandle().getIdentifier();
            runShellCommand("am start-user -w " + userId);
            // Since the test APK isn't installed on the 2nd user, the reason should be unknown.
            assertWithMessage("The test APK should not be installed in the 2nd user").that(
                    mIPackageManager.getPackageInfo(TEST_PKG_NAME, 0 /* flags */, userId)).isNull();
            assertWithMessage("The install reason in 2nd user should be unknown.").that(
                    mIPackageManager.getInstallReason(TEST_PKG_NAME, userId)).isEqualTo(
                    PackageManager.INSTALL_REASON_UNKNOWN);

            // Try to update test APK with different reason INSTALL_REASON_USER
            runShellCommand("pm install --install-reason 4 " + testApk);
            assertWithMessage("The install reason in 2nd user should keep unknown.").that(
                    mIPackageManager.getInstallReason(TEST_PKG_NAME, userId)).isEqualTo(
                    PackageManager.INSTALL_REASON_UNKNOWN);
        } finally {
            runShellCommand("pm uninstall " + TEST_PKG_NAME);
            if (userId != UserHandle.USER_NULL) {