Loading services/tests/uiservicestests/AndroidManifest.xml +1 −0 Original line number Diff line number Diff line Loading @@ -32,6 +32,7 @@ <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" /> <uses-permission android:name="android.permission.OBSERVE_ROLE_HOLDERS" /> <uses-permission android:name="android.permission.GET_INTENT_SENDER_INTENT"/> <uses-permission android:name="android.permission.READ_DEVICE_CONFIG" /> <uses-permission android:name="android.permission.WRITE_DEVICE_CONFIG" /> <uses-permission android:name="android.permission.ACCESS_KEYGUARD_SECURE_STORAGE" /> Loading services/tests/uiservicestests/src/com/android/server/UiServiceTestCase.java +9 −2 Original line number Diff line number Diff line Loading @@ -16,8 +16,10 @@ package com.android.server; import static org.mockito.ArgumentMatchers.any; import static org.mockito.ArgumentMatchers.anyInt; import static org.mockito.ArgumentMatchers.anyString; import static org.mockito.Mockito.spy; import static org.mockito.Mockito.when; import android.content.Intent; import android.content.pm.PackageManagerInternal; import android.net.Uri; import android.os.Build; Loading @@ -44,8 +46,8 @@ public class UiServiceTestCase { protected static final String PKG_R = "com.example.r"; @Rule public final TestableContext mContext = new TestableContext(InstrumentationRegistry.getContext(), null); public TestableContext mContext = spy(new TestableContext(InstrumentationRegistry.getContext(), null)); protected TestableContext getContext() { return mContext; Loading Loading @@ -81,6 +83,11 @@ public class UiServiceTestCase { LocalServices.addService(UriGrantsManagerInternal.class, mUgmInternal); when(mUgmInternal.checkGrantUriPermission( anyInt(), anyString(), any(Uri.class), anyInt(), anyInt())).thenReturn(-1); Mockito.doReturn(new Intent()).when(mContext).registerReceiverAsUser( any(), any(), any(), any(), any()); Mockito.doReturn(new Intent()).when(mContext).registerReceiver(any(), any()); Mockito.doNothing().when(mContext).unregisterReceiver(any()); } @After Loading services/tests/uiservicestests/src/com/android/server/notification/ManagedServicesTest.java +36 −31 Original line number Diff line number Diff line Loading @@ -130,13 +130,18 @@ public class ManagedServicesTest extends UiServiceTestCase { private ArrayMap<Integer, ArrayMap<Integer, String>> mExpectedPrimary; private ArrayMap<Integer, ArrayMap<Integer, String>> mExpectedSecondary; private UserHandle mUser; private String mPkg; @Before public void setUp() throws Exception { MockitoAnnotations.initMocks(this); getContext().setMockPackageManager(mPm); getContext().addMockSystemService(Context.USER_SERVICE, mUm); getContext().addMockSystemService(DEVICE_POLICY_SERVICE, mDpm); mContext.setMockPackageManager(mPm); mContext.addMockSystemService(Context.USER_SERVICE, mUm); mContext.addMockSystemService(DEVICE_POLICY_SERVICE, mDpm); mUser = mContext.getUser(); mPkg = mContext.getPackageName(); List<UserInfo> users = new ArrayList<>(); users.add(mZero); Loading Loading @@ -861,8 +866,8 @@ public class ManagedServicesTest extends UiServiceTestCase { ApplicationInfo ai = new ApplicationInfo(); ai.targetSdkVersion = Build.VERSION_CODES.CUR_DEVELOPMENT; when(context.getPackageName()).thenReturn(mContext.getPackageName()); when(context.getUserId()).thenReturn(mContext.getUserId()); when(context.getPackageName()).thenReturn(mPkg); when(context.getUserId()).thenReturn(mUser.getIdentifier()); when(context.getPackageManager()).thenReturn(pm); when(pm.getApplicationInfo(anyString(), anyInt())).thenReturn(ai); Loading Loading @@ -891,8 +896,8 @@ public class ManagedServicesTest extends UiServiceTestCase { ApplicationInfo ai = new ApplicationInfo(); ai.targetSdkVersion = Build.VERSION_CODES.CUR_DEVELOPMENT; when(context.getPackageName()).thenReturn(mContext.getPackageName()); when(context.getUserId()).thenReturn(mContext.getUserId()); when(context.getPackageName()).thenReturn(mPkg); when(context.getUserId()).thenReturn(mUser.getIdentifier()); when(context.getPackageManager()).thenReturn(pm); when(pm.getApplicationInfo(anyString(), anyInt())).thenReturn(ai); Loading Loading @@ -921,8 +926,8 @@ public class ManagedServicesTest extends UiServiceTestCase { ApplicationInfo ai = new ApplicationInfo(); ai.targetSdkVersion = Build.VERSION_CODES.CUR_DEVELOPMENT; when(context.getPackageName()).thenReturn(mContext.getPackageName()); when(context.getUserId()).thenReturn(mContext.getUserId()); when(context.getPackageName()).thenReturn(mPkg); when(context.getUserId()).thenReturn(mUser.getIdentifier()); when(context.getPackageManager()).thenReturn(pm); when(pm.getApplicationInfo(anyString(), anyInt())).thenReturn(ai); Loading Loading @@ -951,8 +956,8 @@ public class ManagedServicesTest extends UiServiceTestCase { ApplicationInfo ai = new ApplicationInfo(); ai.targetSdkVersion = Build.VERSION_CODES.CUR_DEVELOPMENT; when(context.getPackageName()).thenReturn(mContext.getPackageName()); when(context.getUserId()).thenReturn(mContext.getUserId()); when(context.getPackageName()).thenReturn(mPkg); when(context.getUserId()).thenReturn(mUser.getIdentifier()); when(context.getPackageManager()).thenReturn(pm); when(pm.getApplicationInfo(anyString(), anyInt())).thenReturn(ai); Loading Loading @@ -981,8 +986,8 @@ public class ManagedServicesTest extends UiServiceTestCase { ApplicationInfo ai = new ApplicationInfo(); ai.targetSdkVersion = Build.VERSION_CODES.CUR_DEVELOPMENT; when(context.getPackageName()).thenReturn(mContext.getPackageName()); when(context.getUserId()).thenReturn(mContext.getUserId()); when(context.getPackageName()).thenReturn(mPkg); when(context.getUserId()).thenReturn(mUser.getIdentifier()); when(context.getPackageManager()).thenReturn(pm); when(pm.getApplicationInfo(anyString(), anyInt())).thenReturn(ai); Loading Loading @@ -1011,8 +1016,8 @@ public class ManagedServicesTest extends UiServiceTestCase { ApplicationInfo ai = new ApplicationInfo(); ai.targetSdkVersion = Build.VERSION_CODES.CUR_DEVELOPMENT; when(context.getPackageName()).thenReturn(mContext.getPackageName()); when(context.getUserId()).thenReturn(mContext.getUserId()); when(context.getPackageName()).thenReturn(mPkg); when(context.getUserId()).thenReturn(mUser.getIdentifier()); when(context.getPackageManager()).thenReturn(pm); when(pm.getApplicationInfo(anyString(), anyInt())).thenReturn(ai); Loading Loading @@ -1437,8 +1442,8 @@ public class ManagedServicesTest extends UiServiceTestCase { ApplicationInfo ai = new ApplicationInfo(); ai.targetSdkVersion = Build.VERSION_CODES.CUR_DEVELOPMENT; when(context.getPackageName()).thenReturn(mContext.getPackageName()); when(context.getUserId()).thenReturn(mContext.getUserId()); when(context.getPackageName()).thenReturn(mPkg); when(context.getUserId()).thenReturn(mUser.getIdentifier()); when(context.getPackageManager()).thenReturn(pm); when(pm.getApplicationInfo(anyString(), anyInt())).thenReturn(ai); Loading @@ -1464,8 +1469,8 @@ public class ManagedServicesTest extends UiServiceTestCase { ApplicationInfo ai = new ApplicationInfo(); ai.targetSdkVersion = Build.VERSION_CODES.CUR_DEVELOPMENT; when(context.getPackageName()).thenReturn(mContext.getPackageName()); when(context.getUserId()).thenReturn(mContext.getUserId()); when(context.getPackageName()).thenReturn(mPkg); when(context.getUserId()).thenReturn(mUser.getIdentifier()); when(context.getPackageManager()).thenReturn(pm); when(pm.getApplicationInfo(anyString(), anyInt())).thenReturn(ai); Loading @@ -1492,8 +1497,8 @@ public class ManagedServicesTest extends UiServiceTestCase { ApplicationInfo ai = new ApplicationInfo(); ai.targetSdkVersion = Build.VERSION_CODES.CUR_DEVELOPMENT; when(context.getPackageName()).thenReturn(mContext.getPackageName()); when(context.getUserId()).thenReturn(mContext.getUserId()); when(context.getPackageName()).thenReturn(mPkg); when(context.getUserId()).thenReturn(mUser.getIdentifier()); when(context.getPackageManager()).thenReturn(pm); when(pm.getApplicationInfo(anyString(), anyInt())).thenReturn(ai); Loading Loading @@ -1522,8 +1527,8 @@ public class ManagedServicesTest extends UiServiceTestCase { ApplicationInfo ai = new ApplicationInfo(); ai.targetSdkVersion = Build.VERSION_CODES.CUR_DEVELOPMENT; when(context.getPackageName()).thenReturn(mContext.getPackageName()); when(context.getUserId()).thenReturn(mContext.getUserId()); when(context.getPackageName()).thenReturn(mPkg); when(context.getUserId()).thenReturn(mUser.getIdentifier()); when(context.getPackageManager()).thenReturn(pm); when(pm.getApplicationInfo(anyString(), anyInt())).thenReturn(ai); Loading Loading @@ -1552,8 +1557,8 @@ public class ManagedServicesTest extends UiServiceTestCase { ApplicationInfo ai = new ApplicationInfo(); ai.targetSdkVersion = Build.VERSION_CODES.CUR_DEVELOPMENT; when(context.getPackageName()).thenReturn(mContext.getPackageName()); when(context.getUserId()).thenReturn(mContext.getUserId()); when(context.getPackageName()).thenReturn(mPkg); when(context.getUserId()).thenReturn(mUser.getIdentifier()); when(context.getPackageManager()).thenReturn(pm); when(pm.getApplicationInfo(anyString(), anyInt())).thenReturn(ai); Loading Loading @@ -1791,8 +1796,8 @@ public class ManagedServicesTest extends UiServiceTestCase { ApplicationInfo ai = new ApplicationInfo(); ai.targetSdkVersion = Build.VERSION_CODES.CUR_DEVELOPMENT; when(context.getPackageName()).thenReturn(mContext.getPackageName()); when(context.getUserId()).thenReturn(mContext.getUserId()); when(context.getPackageName()).thenReturn(mPkg); when(context.getUserId()).thenReturn(mUser.getIdentifier()); when(context.getPackageManager()).thenReturn(pm); when(pm.getApplicationInfo(anyString(), anyInt())).thenReturn(ai); Loading Loading @@ -1837,8 +1842,8 @@ public class ManagedServicesTest extends UiServiceTestCase { ApplicationInfo ai = new ApplicationInfo(); ai.targetSdkVersion = Build.VERSION_CODES.CUR_DEVELOPMENT; when(context.getPackageName()).thenReturn(mContext.getPackageName()); when(context.getUserId()).thenReturn(mContext.getUserId()); when(context.getPackageName()).thenReturn(mPkg); when(context.getUserId()).thenReturn(mUser.getIdentifier()); when(context.getPackageManager()).thenReturn(pm); when(pm.getApplicationInfo(anyString(), anyInt())).thenReturn(ai); Loading Loading @@ -1880,8 +1885,8 @@ public class ManagedServicesTest extends UiServiceTestCase { ApplicationInfo ai = new ApplicationInfo(); ai.targetSdkVersion = Build.VERSION_CODES.CUR_DEVELOPMENT; when(context.getPackageName()).thenReturn(mContext.getPackageName()); when(context.getUserId()).thenReturn(mContext.getUserId()); when(context.getPackageName()).thenReturn(mPkg); when(context.getUserId()).thenReturn(mUser.getIdentifier()); when(context.getPackageManager()).thenReturn(pm); when(pm.getApplicationInfo(anyString(), anyInt())).thenReturn(ai); Loading services/tests/uiservicestests/src/com/android/server/notification/NotificationComparatorTest.java +56 −51 File changed.Preview size limit exceeded, changes collapsed. Show changes services/tests/uiservicestests/src/com/android/server/notification/NotificationHistoryDatabaseTest.java +3 −6 Original line number Diff line number Diff line Loading @@ -30,6 +30,7 @@ import android.app.NotificationHistory.HistoricalNotification; import android.content.Context; import android.graphics.drawable.Icon; import android.os.Handler; import android.os.UserHandle; import android.util.AtomicFile; import androidx.test.InstrumentationRegistry; Loading @@ -56,8 +57,6 @@ public class NotificationHistoryDatabaseTest extends UiServiceTestCase { File mRootDir; @Mock Handler mFileWriteHandler; @Mock Context mContext; NotificationHistoryDatabase mDataBase; Loading Loading @@ -92,10 +91,8 @@ public class NotificationHistoryDatabaseTest extends UiServiceTestCase { @Before public void setUp() { MockitoAnnotations.initMocks(this); when(mContext.getUser()).thenReturn(getContext().getUser()); when(mContext.getPackageName()).thenReturn(getContext().getPackageName()); mRootDir = new File(mContext.getFilesDir(), "NotificationHistoryDatabaseTest"); final File fileDir = mContext.getFilesDir(); mRootDir = new File(fileDir, "NotificationHistoryDatabaseTest"); mDataBase = new NotificationHistoryDatabase(mFileWriteHandler, mRootDir); mDataBase.init(); Loading Loading
services/tests/uiservicestests/AndroidManifest.xml +1 −0 Original line number Diff line number Diff line Loading @@ -32,6 +32,7 @@ <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" /> <uses-permission android:name="android.permission.OBSERVE_ROLE_HOLDERS" /> <uses-permission android:name="android.permission.GET_INTENT_SENDER_INTENT"/> <uses-permission android:name="android.permission.READ_DEVICE_CONFIG" /> <uses-permission android:name="android.permission.WRITE_DEVICE_CONFIG" /> <uses-permission android:name="android.permission.ACCESS_KEYGUARD_SECURE_STORAGE" /> Loading
services/tests/uiservicestests/src/com/android/server/UiServiceTestCase.java +9 −2 Original line number Diff line number Diff line Loading @@ -16,8 +16,10 @@ package com.android.server; import static org.mockito.ArgumentMatchers.any; import static org.mockito.ArgumentMatchers.anyInt; import static org.mockito.ArgumentMatchers.anyString; import static org.mockito.Mockito.spy; import static org.mockito.Mockito.when; import android.content.Intent; import android.content.pm.PackageManagerInternal; import android.net.Uri; import android.os.Build; Loading @@ -44,8 +46,8 @@ public class UiServiceTestCase { protected static final String PKG_R = "com.example.r"; @Rule public final TestableContext mContext = new TestableContext(InstrumentationRegistry.getContext(), null); public TestableContext mContext = spy(new TestableContext(InstrumentationRegistry.getContext(), null)); protected TestableContext getContext() { return mContext; Loading Loading @@ -81,6 +83,11 @@ public class UiServiceTestCase { LocalServices.addService(UriGrantsManagerInternal.class, mUgmInternal); when(mUgmInternal.checkGrantUriPermission( anyInt(), anyString(), any(Uri.class), anyInt(), anyInt())).thenReturn(-1); Mockito.doReturn(new Intent()).when(mContext).registerReceiverAsUser( any(), any(), any(), any(), any()); Mockito.doReturn(new Intent()).when(mContext).registerReceiver(any(), any()); Mockito.doNothing().when(mContext).unregisterReceiver(any()); } @After Loading
services/tests/uiservicestests/src/com/android/server/notification/ManagedServicesTest.java +36 −31 Original line number Diff line number Diff line Loading @@ -130,13 +130,18 @@ public class ManagedServicesTest extends UiServiceTestCase { private ArrayMap<Integer, ArrayMap<Integer, String>> mExpectedPrimary; private ArrayMap<Integer, ArrayMap<Integer, String>> mExpectedSecondary; private UserHandle mUser; private String mPkg; @Before public void setUp() throws Exception { MockitoAnnotations.initMocks(this); getContext().setMockPackageManager(mPm); getContext().addMockSystemService(Context.USER_SERVICE, mUm); getContext().addMockSystemService(DEVICE_POLICY_SERVICE, mDpm); mContext.setMockPackageManager(mPm); mContext.addMockSystemService(Context.USER_SERVICE, mUm); mContext.addMockSystemService(DEVICE_POLICY_SERVICE, mDpm); mUser = mContext.getUser(); mPkg = mContext.getPackageName(); List<UserInfo> users = new ArrayList<>(); users.add(mZero); Loading Loading @@ -861,8 +866,8 @@ public class ManagedServicesTest extends UiServiceTestCase { ApplicationInfo ai = new ApplicationInfo(); ai.targetSdkVersion = Build.VERSION_CODES.CUR_DEVELOPMENT; when(context.getPackageName()).thenReturn(mContext.getPackageName()); when(context.getUserId()).thenReturn(mContext.getUserId()); when(context.getPackageName()).thenReturn(mPkg); when(context.getUserId()).thenReturn(mUser.getIdentifier()); when(context.getPackageManager()).thenReturn(pm); when(pm.getApplicationInfo(anyString(), anyInt())).thenReturn(ai); Loading Loading @@ -891,8 +896,8 @@ public class ManagedServicesTest extends UiServiceTestCase { ApplicationInfo ai = new ApplicationInfo(); ai.targetSdkVersion = Build.VERSION_CODES.CUR_DEVELOPMENT; when(context.getPackageName()).thenReturn(mContext.getPackageName()); when(context.getUserId()).thenReturn(mContext.getUserId()); when(context.getPackageName()).thenReturn(mPkg); when(context.getUserId()).thenReturn(mUser.getIdentifier()); when(context.getPackageManager()).thenReturn(pm); when(pm.getApplicationInfo(anyString(), anyInt())).thenReturn(ai); Loading Loading @@ -921,8 +926,8 @@ public class ManagedServicesTest extends UiServiceTestCase { ApplicationInfo ai = new ApplicationInfo(); ai.targetSdkVersion = Build.VERSION_CODES.CUR_DEVELOPMENT; when(context.getPackageName()).thenReturn(mContext.getPackageName()); when(context.getUserId()).thenReturn(mContext.getUserId()); when(context.getPackageName()).thenReturn(mPkg); when(context.getUserId()).thenReturn(mUser.getIdentifier()); when(context.getPackageManager()).thenReturn(pm); when(pm.getApplicationInfo(anyString(), anyInt())).thenReturn(ai); Loading Loading @@ -951,8 +956,8 @@ public class ManagedServicesTest extends UiServiceTestCase { ApplicationInfo ai = new ApplicationInfo(); ai.targetSdkVersion = Build.VERSION_CODES.CUR_DEVELOPMENT; when(context.getPackageName()).thenReturn(mContext.getPackageName()); when(context.getUserId()).thenReturn(mContext.getUserId()); when(context.getPackageName()).thenReturn(mPkg); when(context.getUserId()).thenReturn(mUser.getIdentifier()); when(context.getPackageManager()).thenReturn(pm); when(pm.getApplicationInfo(anyString(), anyInt())).thenReturn(ai); Loading Loading @@ -981,8 +986,8 @@ public class ManagedServicesTest extends UiServiceTestCase { ApplicationInfo ai = new ApplicationInfo(); ai.targetSdkVersion = Build.VERSION_CODES.CUR_DEVELOPMENT; when(context.getPackageName()).thenReturn(mContext.getPackageName()); when(context.getUserId()).thenReturn(mContext.getUserId()); when(context.getPackageName()).thenReturn(mPkg); when(context.getUserId()).thenReturn(mUser.getIdentifier()); when(context.getPackageManager()).thenReturn(pm); when(pm.getApplicationInfo(anyString(), anyInt())).thenReturn(ai); Loading Loading @@ -1011,8 +1016,8 @@ public class ManagedServicesTest extends UiServiceTestCase { ApplicationInfo ai = new ApplicationInfo(); ai.targetSdkVersion = Build.VERSION_CODES.CUR_DEVELOPMENT; when(context.getPackageName()).thenReturn(mContext.getPackageName()); when(context.getUserId()).thenReturn(mContext.getUserId()); when(context.getPackageName()).thenReturn(mPkg); when(context.getUserId()).thenReturn(mUser.getIdentifier()); when(context.getPackageManager()).thenReturn(pm); when(pm.getApplicationInfo(anyString(), anyInt())).thenReturn(ai); Loading Loading @@ -1437,8 +1442,8 @@ public class ManagedServicesTest extends UiServiceTestCase { ApplicationInfo ai = new ApplicationInfo(); ai.targetSdkVersion = Build.VERSION_CODES.CUR_DEVELOPMENT; when(context.getPackageName()).thenReturn(mContext.getPackageName()); when(context.getUserId()).thenReturn(mContext.getUserId()); when(context.getPackageName()).thenReturn(mPkg); when(context.getUserId()).thenReturn(mUser.getIdentifier()); when(context.getPackageManager()).thenReturn(pm); when(pm.getApplicationInfo(anyString(), anyInt())).thenReturn(ai); Loading @@ -1464,8 +1469,8 @@ public class ManagedServicesTest extends UiServiceTestCase { ApplicationInfo ai = new ApplicationInfo(); ai.targetSdkVersion = Build.VERSION_CODES.CUR_DEVELOPMENT; when(context.getPackageName()).thenReturn(mContext.getPackageName()); when(context.getUserId()).thenReturn(mContext.getUserId()); when(context.getPackageName()).thenReturn(mPkg); when(context.getUserId()).thenReturn(mUser.getIdentifier()); when(context.getPackageManager()).thenReturn(pm); when(pm.getApplicationInfo(anyString(), anyInt())).thenReturn(ai); Loading @@ -1492,8 +1497,8 @@ public class ManagedServicesTest extends UiServiceTestCase { ApplicationInfo ai = new ApplicationInfo(); ai.targetSdkVersion = Build.VERSION_CODES.CUR_DEVELOPMENT; when(context.getPackageName()).thenReturn(mContext.getPackageName()); when(context.getUserId()).thenReturn(mContext.getUserId()); when(context.getPackageName()).thenReturn(mPkg); when(context.getUserId()).thenReturn(mUser.getIdentifier()); when(context.getPackageManager()).thenReturn(pm); when(pm.getApplicationInfo(anyString(), anyInt())).thenReturn(ai); Loading Loading @@ -1522,8 +1527,8 @@ public class ManagedServicesTest extends UiServiceTestCase { ApplicationInfo ai = new ApplicationInfo(); ai.targetSdkVersion = Build.VERSION_CODES.CUR_DEVELOPMENT; when(context.getPackageName()).thenReturn(mContext.getPackageName()); when(context.getUserId()).thenReturn(mContext.getUserId()); when(context.getPackageName()).thenReturn(mPkg); when(context.getUserId()).thenReturn(mUser.getIdentifier()); when(context.getPackageManager()).thenReturn(pm); when(pm.getApplicationInfo(anyString(), anyInt())).thenReturn(ai); Loading Loading @@ -1552,8 +1557,8 @@ public class ManagedServicesTest extends UiServiceTestCase { ApplicationInfo ai = new ApplicationInfo(); ai.targetSdkVersion = Build.VERSION_CODES.CUR_DEVELOPMENT; when(context.getPackageName()).thenReturn(mContext.getPackageName()); when(context.getUserId()).thenReturn(mContext.getUserId()); when(context.getPackageName()).thenReturn(mPkg); when(context.getUserId()).thenReturn(mUser.getIdentifier()); when(context.getPackageManager()).thenReturn(pm); when(pm.getApplicationInfo(anyString(), anyInt())).thenReturn(ai); Loading Loading @@ -1791,8 +1796,8 @@ public class ManagedServicesTest extends UiServiceTestCase { ApplicationInfo ai = new ApplicationInfo(); ai.targetSdkVersion = Build.VERSION_CODES.CUR_DEVELOPMENT; when(context.getPackageName()).thenReturn(mContext.getPackageName()); when(context.getUserId()).thenReturn(mContext.getUserId()); when(context.getPackageName()).thenReturn(mPkg); when(context.getUserId()).thenReturn(mUser.getIdentifier()); when(context.getPackageManager()).thenReturn(pm); when(pm.getApplicationInfo(anyString(), anyInt())).thenReturn(ai); Loading Loading @@ -1837,8 +1842,8 @@ public class ManagedServicesTest extends UiServiceTestCase { ApplicationInfo ai = new ApplicationInfo(); ai.targetSdkVersion = Build.VERSION_CODES.CUR_DEVELOPMENT; when(context.getPackageName()).thenReturn(mContext.getPackageName()); when(context.getUserId()).thenReturn(mContext.getUserId()); when(context.getPackageName()).thenReturn(mPkg); when(context.getUserId()).thenReturn(mUser.getIdentifier()); when(context.getPackageManager()).thenReturn(pm); when(pm.getApplicationInfo(anyString(), anyInt())).thenReturn(ai); Loading Loading @@ -1880,8 +1885,8 @@ public class ManagedServicesTest extends UiServiceTestCase { ApplicationInfo ai = new ApplicationInfo(); ai.targetSdkVersion = Build.VERSION_CODES.CUR_DEVELOPMENT; when(context.getPackageName()).thenReturn(mContext.getPackageName()); when(context.getUserId()).thenReturn(mContext.getUserId()); when(context.getPackageName()).thenReturn(mPkg); when(context.getUserId()).thenReturn(mUser.getIdentifier()); when(context.getPackageManager()).thenReturn(pm); when(pm.getApplicationInfo(anyString(), anyInt())).thenReturn(ai); Loading
services/tests/uiservicestests/src/com/android/server/notification/NotificationComparatorTest.java +56 −51 File changed.Preview size limit exceeded, changes collapsed. Show changes
services/tests/uiservicestests/src/com/android/server/notification/NotificationHistoryDatabaseTest.java +3 −6 Original line number Diff line number Diff line Loading @@ -30,6 +30,7 @@ import android.app.NotificationHistory.HistoricalNotification; import android.content.Context; import android.graphics.drawable.Icon; import android.os.Handler; import android.os.UserHandle; import android.util.AtomicFile; import androidx.test.InstrumentationRegistry; Loading @@ -56,8 +57,6 @@ public class NotificationHistoryDatabaseTest extends UiServiceTestCase { File mRootDir; @Mock Handler mFileWriteHandler; @Mock Context mContext; NotificationHistoryDatabase mDataBase; Loading Loading @@ -92,10 +91,8 @@ public class NotificationHistoryDatabaseTest extends UiServiceTestCase { @Before public void setUp() { MockitoAnnotations.initMocks(this); when(mContext.getUser()).thenReturn(getContext().getUser()); when(mContext.getPackageName()).thenReturn(getContext().getPackageName()); mRootDir = new File(mContext.getFilesDir(), "NotificationHistoryDatabaseTest"); final File fileDir = mContext.getFilesDir(); mRootDir = new File(fileDir, "NotificationHistoryDatabaseTest"); mDataBase = new NotificationHistoryDatabase(mFileWriteHandler, mRootDir); mDataBase.init(); Loading