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

Commit 20292783 authored by Tadashi G. Takaoka's avatar Tadashi G. Takaoka
Browse files

Fix NPE of CoreSettingsObserverTest

This is a follow up of Ibf515ddcf384bc643c568243b675efb61f0bbd66.

Bug: 171283021
Bug: 142676371
Test: atest FrameworksServicesTests:CoreSettingObserverTest
Change-Id: I2f808828eba79147fea3a88279effffb7b5b20a4
parent 05e768ce
Loading
Loading
Loading
Loading
+6 −2
Original line number Diff line number Diff line
@@ -23,7 +23,7 @@ import static com.android.server.am.ActivityManagerService.Injector;
import static com.google.common.truth.Truth.assertWithMessage;

import static org.junit.Assert.assertEquals;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.anyInt;
import static org.mockito.Mockito.when;

import android.content.Context;
@@ -68,6 +68,7 @@ public class CoreSettingsObserverTest {

    private ActivityManagerService mAms;
    @Mock private Context mContext;
    @Mock private Resources mResources;

    private MockContentResolver mContentResolver;
    private CoreSettingsObserver mCoreSettingsObserver;
@@ -94,7 +95,10 @@ public class CoreSettingsObserverTest {
        mContentResolver = new MockContentResolver(mContext);
        mContentResolver.addProvider(Settings.AUTHORITY, new FakeSettingsProvider());
        when(mContext.getContentResolver()).thenReturn(mContentResolver);
        when(mContext.getResources()).thenReturn(mock(Resources.class));
        when(mContext.getResources()).thenReturn(mResources);
        // To prevent NullPointerException at the constructor of ActivityManagerConstants.
        when(mResources.getStringArray(anyInt())).thenReturn(new String[0]);
        when(mResources.getIntArray(anyInt())).thenReturn(new int[0]);

        mAms = new ActivityManagerService(new TestInjector(mContext),
                mServiceThreadRule.getThread());