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

Commit c8d5701a authored by Fan Wu's avatar Fan Wu Committed by Android (Google) Code Review
Browse files

Merge "Fix AppInfoWithHeaderTest" into main

parents a0f50eb5 75763322
Loading
Loading
Loading
Loading
+13 −14
Original line number Diff line number Diff line
@@ -19,6 +19,7 @@ package com.android.settings.applications;
import static com.google.common.truth.Truth.assertThat;

import static org.mockito.ArgumentMatchers.any;
import static org.mockito.ArgumentMatchers.eq;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;
@@ -48,12 +49,13 @@ import com.android.settingslib.widget.LayoutPreference;

import org.junit.After;
import org.junit.Before;
import org.junit.Ignore;
import org.junit.Rule;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.Answers;
import org.mockito.Mock;
import org.mockito.MockitoAnnotations;
import org.mockito.junit.MockitoJUnit;
import org.mockito.junit.MockitoRule;
import org.robolectric.RobolectricTestRunner;
import org.robolectric.RuntimeEnvironment;
import org.robolectric.annotation.Config;
@@ -62,6 +64,8 @@ import org.robolectric.util.ReflectionHelpers;
@RunWith(RobolectricTestRunner.class)
@Config(shadows = {ShadowEntityHeaderController.class, ShadowSettingsLibUtils.class})
public class AppInfoWithHeaderTest {
    @Rule
    public final MockitoRule mMockitoRule = MockitoJUnit.rule();

    @Mock(answer = Answers.RETURNS_DEEP_STUBS)
    private EntityHeaderController mHeaderController;
@@ -71,7 +75,6 @@ public class AppInfoWithHeaderTest {

    @Before
    public void setUp() {
        MockitoAnnotations.initMocks(this);
        mFactory = FakeFeatureFactory.setupForTest();
        when(mFactory.metricsFeatureProvider.getMetricsCategory(any(Object.class)))
                .thenReturn(MetricsProto.MetricsEvent.SETTINGS_APP_NOTIF_CATEGORY);
@@ -120,7 +123,6 @@ public class AppInfoWithHeaderTest {
        assertThat(mAppInfoWithHeader.mPackageRemovedCalled).isTrue();
    }

    @Ignore("b/315135755")
    @Test
    public void noExtraUserHandleInIntent_retrieveAppEntryWithMyUserId()
            throws PackageManager.NameNotFoundException {
@@ -133,10 +135,8 @@ public class AppInfoWithHeaderTest {

        when(mAppInfoWithHeader.mState.getEntry(packageName,
                UserHandle.myUserId())).thenReturn(entry);
        when(mAppInfoWithHeader.mPm.getPackageInfoAsUser(entry.info.packageName,
                PackageManager.MATCH_DISABLED_COMPONENTS |
                        PackageManager.GET_SIGNING_CERTIFICATES |
                        PackageManager.GET_PERMISSIONS, UserHandle.myUserId())).thenReturn(
        when(mAppInfoWithHeader.mPm.getPackageInfoAsUser(eq(entry.info.packageName),
                any(), eq(UserHandle.myUserId()))).thenReturn(
                mAppInfoWithHeader.mPackageInfo);

        mAppInfoWithHeader.retrieveAppEntry();
@@ -146,7 +146,6 @@ public class AppInfoWithHeaderTest {
        assertThat(mAppInfoWithHeader.mAppEntry).isNotNull();
    }

    @Ignore("b/315135755")
    @Test
    public void extraUserHandleInIntent_retrieveAppEntryWithMyUserId()
            throws PackageManager.NameNotFoundException {
@@ -161,10 +160,8 @@ public class AppInfoWithHeaderTest {
        entry.info.packageName = packageName;

        when(mAppInfoWithHeader.mState.getEntry(packageName, USER_ID)).thenReturn(entry);
        when(mAppInfoWithHeader.mPm.getPackageInfoAsUser(entry.info.packageName,
                PackageManager.MATCH_DISABLED_COMPONENTS |
                        PackageManager.GET_SIGNING_CERTIFICATES |
                        PackageManager.GET_PERMISSIONS, USER_ID)).thenReturn(
        when(mAppInfoWithHeader.mPm.getPackageInfoAsUser(eq(entry.info.packageName),
                any(), eq(USER_ID))).thenReturn(
                mAppInfoWithHeader.mPackageInfo);

        mAppInfoWithHeader.retrieveAppEntry();
@@ -232,6 +229,8 @@ public class AppInfoWithHeaderTest {
        }

        @Override
        protected Intent getIntent() { return mIntent; }
        protected Intent getIntent() {
            return mIntent;
        }
    }
}