use of org.robolectric.res.builder.RobolectricPackageManager in project Parse-SDK-Android by ParsePlatform.
the class ParseInstallationTest method mocksForUpdateBeforeSave.
// TODO(mengyan): Add testFetchAsync, right now we can not test super methods inside
// testFetchAsync
private static void mocksForUpdateBeforeSave() {
// Mock currentInstallationController to make setAsync work
ParseCurrentInstallationController controller = mock(ParseCurrentInstallationController.class);
when(controller.isCurrent(any(ParseInstallation.class))).thenReturn(true);
ParseCorePlugins.getInstance().registerCurrentInstallationController(controller);
// Mock package manager
RobolectricPackageManager packageManager = spy(RuntimeEnvironment.getRobolectricPackageManager());
doReturn("parseTest").when(packageManager).getApplicationLabel(any(ApplicationInfo.class));
RuntimeEnvironment.setRobolectricPackageManager(packageManager);
ParsePlugins.Android plugins = mock(ParsePlugins.Android.class);
// Mock installationId
InstallationId installationId = mock(InstallationId.class);
when(installationId.get()).thenReturn("installationId");
when(plugins.installationId()).thenReturn(installationId);
// Mock application context
when(plugins.applicationContext()).thenReturn(RuntimeEnvironment.application);
ParsePlugins.set(plugins);
}
Aggregations