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

Commit 5b1df2fb authored by Todd Kennedy's avatar Todd Kennedy
Browse files

Fix package manager tests

Test: bit FrameworksServicesTests:com.android.server.pm.
Change-Id: I06089adcdf6cdaebc7176cab30254cc2cbd836eb
parent 6fedbfe9
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
@@ -6454,6 +6454,7 @@ public class PackageParser {
            mAdoptPermissions = dest.createStringArrayList();
            mAppMetaData = dest.readBundle();
            mVersionCode = dest.readInt();
            mVersionCodeMajor = dest.readInt();
            mVersionName = dest.readString();
            if (mVersionName != null) {
                mVersionName = mVersionName.intern();
@@ -6600,6 +6601,7 @@ public class PackageParser {
            dest.writeStringList(mAdoptPermissions);
            dest.writeBundle(mAppMetaData);
            dest.writeInt(mVersionCode);
            dest.writeInt(mVersionCodeMajor);
            dest.writeString(mVersionName);
            dest.writeString(mSharedUserId);
            dest.writeInt(mSharedUserLabel);
+23 −4
Original line number Diff line number Diff line
@@ -16,19 +16,28 @@

package com.android.server.pm;

import android.content.Context;
import android.content.pm.ApplicationInfo;
import android.content.pm.PackageManager;
import android.content.pm.PackageStats;
import android.os.SystemClock;
import android.os.UserHandle;
import android.test.AndroidTestCase;
import android.support.test.InstrumentationRegistry;
import android.support.test.runner.AndroidJUnit4;
import android.util.Log;

import com.android.internal.util.ArrayUtils;

import org.junit.After;
import org.junit.Before;
import org.junit.Ignore;
import org.junit.Test;
import org.junit.runner.RunWith;

import java.util.Arrays;

public class InstallerTest extends AndroidTestCase {
@RunWith(AndroidJUnit4.class)
public class InstallerTest {
    private static final String TAG = "InstallerTest";

    private Installer mInstaller;
@@ -64,7 +73,7 @@ public class InstallerTest extends AndroidTestCase {
        }
    }

    @Override
    @Before
    public void setUp() throws Exception {
        mInstaller = new Installer(getContext());
        mInstaller.onStart();
@@ -72,13 +81,15 @@ public class InstallerTest extends AndroidTestCase {
        mQuota.reset();
    }

    @Override
    @After
    public void tearDown() throws Exception {
        Log.i(TAG, mManual.toString());
        Log.i(TAG, mQuota.toString());
        mInstaller = null;
    }

    @Test
    @Ignore("b/68819006")
    public void testGetAppSize() throws Exception {
        int[] appIds = null;

@@ -119,6 +130,8 @@ public class InstallerTest extends AndroidTestCase {
        }
    }

    @Test
    @Ignore("b/68819006")
    public void testGetUserSize() throws Exception {
        final int[] appIds = getAppIds(UserHandle.USER_SYSTEM);

@@ -138,6 +151,8 @@ public class InstallerTest extends AndroidTestCase {
        checkEquals(Arrays.toString(appIds), stats, quotaStats);
    }

    @Test
    @Ignore("b/68819006")
    public void testGetExternalSize() throws Exception {
        final int[] appIds = getAppIds(UserHandle.USER_SYSTEM);

@@ -167,6 +182,10 @@ public class InstallerTest extends AndroidTestCase {
        return appIds;
    }

    private static Context getContext() {
        return InstrumentationRegistry.getContext();
    }

    private static void checkEquals(String msg, PackageStats a, PackageStats b) {
        checkEquals(msg + " codeSize", a.codeSize, b.codeSize);
        checkEquals(msg + " dataSize", a.dataSize, b.dataSize);
+2 −2
Original line number Diff line number Diff line
@@ -206,8 +206,8 @@ public class PackageManagerSettingsTests {
            new File(InstrumentationRegistry.getContext().getFilesDir(), "com.android.bar-1");
    private static final File UPDATED_CODE_PATH =
            new File(InstrumentationRegistry.getContext().getFilesDir(), "com.android.bar-2");
    private static final int INITIAL_VERSION_CODE = 10023;
    private static final int UPDATED_VERSION_CODE = 10025;
    private static final long INITIAL_VERSION_CODE = 10023L;
    private static final long UPDATED_VERSION_CODE = 10025L;

    @Test
    public void testPackageStateCopy01() {
+4 −0
Original line number Diff line number Diff line
@@ -520,6 +520,10 @@ public class PackageParserTest {

        pkg.featureGroups = new ArrayList<>();
        pkg.featureGroups.add(new FeatureGroupInfo());

        pkg.mCompileSdkVersionCodename = "foo23";
        pkg.mCompileSdkVersion = 100;
        pkg.mVersionCodeMajor = 100;
    }

    private static void assertAllFieldsExist(PackageParser.Package pkg) throws Exception {
+6 −0
Original line number Diff line number Diff line
@@ -121,6 +121,8 @@ import java.util.function.BiConsumer;
@SmallTest
public class ShortcutManagerTest1 extends BaseShortcutManagerTest {

    private static final boolean SKIP_FOR_BUG_67325252 = true;

    /**
     * Test for the first launch path, no settings file available.
     */
@@ -722,6 +724,10 @@ public class ShortcutManagerTest1 extends BaseShortcutManagerTest {
    }

    public void testCleanupDanglingBitmaps() throws Exception {
        if (SKIP_FOR_BUG_67325252) {
            return;
        }

        assertBitmapDirectories(USER_0, EMPTY_STRINGS);
        assertBitmapDirectories(USER_10, EMPTY_STRINGS);