Merge "Fix AppInfoWithHeaderTest" into main
This commit is contained in:
@@ -19,6 +19,7 @@ package com.android.settings.applications;
|
|||||||
import static com.google.common.truth.Truth.assertThat;
|
import static com.google.common.truth.Truth.assertThat;
|
||||||
|
|
||||||
import static org.mockito.ArgumentMatchers.any;
|
import static org.mockito.ArgumentMatchers.any;
|
||||||
|
import static org.mockito.ArgumentMatchers.eq;
|
||||||
import static org.mockito.Mockito.mock;
|
import static org.mockito.Mockito.mock;
|
||||||
import static org.mockito.Mockito.verify;
|
import static org.mockito.Mockito.verify;
|
||||||
import static org.mockito.Mockito.when;
|
import static org.mockito.Mockito.when;
|
||||||
@@ -48,12 +49,13 @@ import com.android.settingslib.widget.LayoutPreference;
|
|||||||
|
|
||||||
import org.junit.After;
|
import org.junit.After;
|
||||||
import org.junit.Before;
|
import org.junit.Before;
|
||||||
import org.junit.Ignore;
|
import org.junit.Rule;
|
||||||
import org.junit.Test;
|
import org.junit.Test;
|
||||||
import org.junit.runner.RunWith;
|
import org.junit.runner.RunWith;
|
||||||
import org.mockito.Answers;
|
import org.mockito.Answers;
|
||||||
import org.mockito.Mock;
|
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.RobolectricTestRunner;
|
||||||
import org.robolectric.RuntimeEnvironment;
|
import org.robolectric.RuntimeEnvironment;
|
||||||
import org.robolectric.annotation.Config;
|
import org.robolectric.annotation.Config;
|
||||||
@@ -62,6 +64,8 @@ import org.robolectric.util.ReflectionHelpers;
|
|||||||
@RunWith(RobolectricTestRunner.class)
|
@RunWith(RobolectricTestRunner.class)
|
||||||
@Config(shadows = {ShadowEntityHeaderController.class, ShadowSettingsLibUtils.class})
|
@Config(shadows = {ShadowEntityHeaderController.class, ShadowSettingsLibUtils.class})
|
||||||
public class AppInfoWithHeaderTest {
|
public class AppInfoWithHeaderTest {
|
||||||
|
@Rule
|
||||||
|
public final MockitoRule mMockitoRule = MockitoJUnit.rule();
|
||||||
|
|
||||||
@Mock(answer = Answers.RETURNS_DEEP_STUBS)
|
@Mock(answer = Answers.RETURNS_DEEP_STUBS)
|
||||||
private EntityHeaderController mHeaderController;
|
private EntityHeaderController mHeaderController;
|
||||||
@@ -71,7 +75,6 @@ public class AppInfoWithHeaderTest {
|
|||||||
|
|
||||||
@Before
|
@Before
|
||||||
public void setUp() {
|
public void setUp() {
|
||||||
MockitoAnnotations.initMocks(this);
|
|
||||||
mFactory = FakeFeatureFactory.setupForTest();
|
mFactory = FakeFeatureFactory.setupForTest();
|
||||||
when(mFactory.metricsFeatureProvider.getMetricsCategory(any(Object.class)))
|
when(mFactory.metricsFeatureProvider.getMetricsCategory(any(Object.class)))
|
||||||
.thenReturn(MetricsProto.MetricsEvent.SETTINGS_APP_NOTIF_CATEGORY);
|
.thenReturn(MetricsProto.MetricsEvent.SETTINGS_APP_NOTIF_CATEGORY);
|
||||||
@@ -120,7 +123,6 @@ public class AppInfoWithHeaderTest {
|
|||||||
assertThat(mAppInfoWithHeader.mPackageRemovedCalled).isTrue();
|
assertThat(mAppInfoWithHeader.mPackageRemovedCalled).isTrue();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Ignore("b/315135755")
|
|
||||||
@Test
|
@Test
|
||||||
public void noExtraUserHandleInIntent_retrieveAppEntryWithMyUserId()
|
public void noExtraUserHandleInIntent_retrieveAppEntryWithMyUserId()
|
||||||
throws PackageManager.NameNotFoundException {
|
throws PackageManager.NameNotFoundException {
|
||||||
@@ -133,10 +135,8 @@ public class AppInfoWithHeaderTest {
|
|||||||
|
|
||||||
when(mAppInfoWithHeader.mState.getEntry(packageName,
|
when(mAppInfoWithHeader.mState.getEntry(packageName,
|
||||||
UserHandle.myUserId())).thenReturn(entry);
|
UserHandle.myUserId())).thenReturn(entry);
|
||||||
when(mAppInfoWithHeader.mPm.getPackageInfoAsUser(entry.info.packageName,
|
when(mAppInfoWithHeader.mPm.getPackageInfoAsUser(eq(entry.info.packageName),
|
||||||
PackageManager.MATCH_DISABLED_COMPONENTS |
|
any(), eq(UserHandle.myUserId()))).thenReturn(
|
||||||
PackageManager.GET_SIGNING_CERTIFICATES |
|
|
||||||
PackageManager.GET_PERMISSIONS, UserHandle.myUserId())).thenReturn(
|
|
||||||
mAppInfoWithHeader.mPackageInfo);
|
mAppInfoWithHeader.mPackageInfo);
|
||||||
|
|
||||||
mAppInfoWithHeader.retrieveAppEntry();
|
mAppInfoWithHeader.retrieveAppEntry();
|
||||||
@@ -146,7 +146,6 @@ public class AppInfoWithHeaderTest {
|
|||||||
assertThat(mAppInfoWithHeader.mAppEntry).isNotNull();
|
assertThat(mAppInfoWithHeader.mAppEntry).isNotNull();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Ignore("b/315135755")
|
|
||||||
@Test
|
@Test
|
||||||
public void extraUserHandleInIntent_retrieveAppEntryWithMyUserId()
|
public void extraUserHandleInIntent_retrieveAppEntryWithMyUserId()
|
||||||
throws PackageManager.NameNotFoundException {
|
throws PackageManager.NameNotFoundException {
|
||||||
@@ -161,10 +160,8 @@ public class AppInfoWithHeaderTest {
|
|||||||
entry.info.packageName = packageName;
|
entry.info.packageName = packageName;
|
||||||
|
|
||||||
when(mAppInfoWithHeader.mState.getEntry(packageName, USER_ID)).thenReturn(entry);
|
when(mAppInfoWithHeader.mState.getEntry(packageName, USER_ID)).thenReturn(entry);
|
||||||
when(mAppInfoWithHeader.mPm.getPackageInfoAsUser(entry.info.packageName,
|
when(mAppInfoWithHeader.mPm.getPackageInfoAsUser(eq(entry.info.packageName),
|
||||||
PackageManager.MATCH_DISABLED_COMPONENTS |
|
any(), eq(USER_ID))).thenReturn(
|
||||||
PackageManager.GET_SIGNING_CERTIFICATES |
|
|
||||||
PackageManager.GET_PERMISSIONS, USER_ID)).thenReturn(
|
|
||||||
mAppInfoWithHeader.mPackageInfo);
|
mAppInfoWithHeader.mPackageInfo);
|
||||||
|
|
||||||
mAppInfoWithHeader.retrieveAppEntry();
|
mAppInfoWithHeader.retrieveAppEntry();
|
||||||
@@ -232,6 +229,8 @@ public class AppInfoWithHeaderTest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected Intent getIntent() { return mIntent; }
|
protected Intent getIntent() {
|
||||||
|
return mIntent;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user