Mock some methods of Context in CoreSettingsObserverTest

In order to fix the test NPE during set up.

Bug: 264668735
Test: com.android.server.am.CoreSettingsObserverTest
Change-Id: I452bb7730c9d3b39cbec32c9e71525a079941456
This commit is contained in:
Hiroki Sato
2023-01-10 16:19:18 +09:00
parent df667b485f
commit 387f32a214

View File

@@ -97,6 +97,8 @@ public class CoreSettingsObserverTest {
mContentResolver = new MockContentResolver(mContext);
mContentResolver.addProvider(Settings.AUTHORITY, new FakeSettingsProvider());
when(mContext.getContentResolver()).thenReturn(mContentResolver);
when(mContext.getCacheDir()).thenReturn(originalContext.getCacheDir());
when(mContext.getAttributionSource()).thenReturn(originalContext.getAttributionSource());
when(mContext.getResources()).thenReturn(mResources);
// To prevent NullPointerException at the constructor of ActivityManagerConstants.
when(mResources.getStringArray(anyInt())).thenReturn(new String[0]);