Fixes broken Settings test.
In ag/22187500, we added the requirement for a wallpaper picker app to be installed in order to treat the lock screen shortcuts feature as enabled (in addition to the feature flag). That broke this test. To fix, we're adding a mocked result to the PackageManager to pretend like the wallpaper picker application is installed. Change-Id: I8654375e3fa33df0984c48fcf91dd8f6c18e984f Fix: 280017187 Test: the test is back to passing.
This commit is contained in:
@@ -18,6 +18,7 @@ package com.android.settings.display;
|
|||||||
|
|
||||||
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.anyBoolean;
|
import static org.mockito.ArgumentMatchers.anyBoolean;
|
||||||
import static org.mockito.ArgumentMatchers.anyString;
|
import static org.mockito.ArgumentMatchers.anyString;
|
||||||
import static org.mockito.Mockito.atLeastOnce;
|
import static org.mockito.Mockito.atLeastOnce;
|
||||||
@@ -27,6 +28,10 @@ import static org.mockito.Mockito.when;
|
|||||||
|
|
||||||
import android.content.ContentResolver;
|
import android.content.ContentResolver;
|
||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
|
import android.content.pm.ActivityInfo;
|
||||||
|
import android.content.pm.ApplicationInfo;
|
||||||
|
import android.content.pm.PackageManager;
|
||||||
|
import android.content.pm.ResolveInfo;
|
||||||
import android.database.Cursor;
|
import android.database.Cursor;
|
||||||
import android.database.MatrixCursor;
|
import android.database.MatrixCursor;
|
||||||
import android.provider.Settings;
|
import android.provider.Settings;
|
||||||
@@ -64,12 +69,16 @@ public class ControlsTrivialPrivacyPreferenceControllerTest {
|
|||||||
@Mock
|
@Mock
|
||||||
private PreferenceScreen mPreferenceScreen;
|
private PreferenceScreen mPreferenceScreen;
|
||||||
|
|
||||||
|
@Mock
|
||||||
|
private PackageManager mPackageManager;
|
||||||
|
|
||||||
@Before
|
@Before
|
||||||
public void setUp() {
|
public void setUp() {
|
||||||
MockitoAnnotations.initMocks(this);
|
MockitoAnnotations.initMocks(this);
|
||||||
mContext = spy(ApplicationProvider.getApplicationContext());
|
mContext = spy(ApplicationProvider.getApplicationContext());
|
||||||
mContentResolver = spy(mContext.getContentResolver());
|
mContentResolver = spy(mContext.getContentResolver());
|
||||||
when(mContext.getContentResolver()).thenReturn(mContentResolver);
|
when(mContext.getContentResolver()).thenReturn(mContentResolver);
|
||||||
|
when(mContext.getPackageManager()).thenReturn(mPackageManager);
|
||||||
|
|
||||||
setCustomizableLockScreenQuickAffordancesEnabled(false);
|
setCustomizableLockScreenQuickAffordancesEnabled(false);
|
||||||
|
|
||||||
@@ -199,5 +208,19 @@ public class ControlsTrivialPrivacyPreferenceControllerTest {
|
|||||||
});
|
});
|
||||||
return cursor;
|
return cursor;
|
||||||
});
|
});
|
||||||
|
|
||||||
|
if (isEnabled) {
|
||||||
|
final ApplicationInfo applicationInfo = new ApplicationInfo();
|
||||||
|
applicationInfo.packageName = "package";
|
||||||
|
|
||||||
|
final ActivityInfo activityInfo = new ActivityInfo();
|
||||||
|
activityInfo.applicationInfo = applicationInfo;
|
||||||
|
activityInfo.name = "activity";
|
||||||
|
|
||||||
|
final ResolveInfo resolveInfo = new ResolveInfo();
|
||||||
|
resolveInfo.activityInfo = activityInfo;
|
||||||
|
|
||||||
|
when(mPackageManager.resolveActivity(any(), any())).thenReturn(resolveInfo);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user