use of org.powermock.core.classloader.annotations.PrepareForTest in project mobile-center-sdk-android by Microsoft.
the class DistributeWarnUnknownSourcesTest method clickSettingsOnAndroidO.
@Test
@PrepareForTest(Build.class)
@SuppressLint("InlinedApi")
public void clickSettingsOnAndroidO() throws Exception {
/* Click settings. */
Intent intentSecuritySettings = mock(Intent.class);
whenNew(Intent.class).withArguments(Settings.ACTION_SECURITY_SETTINGS).thenReturn(intentSecuritySettings);
Intent intentManageUnknownAppSources = mock(Intent.class);
whenNew(Intent.class).withArguments(Settings.ACTION_MANAGE_UNKNOWN_APP_SOURCES).thenReturn(intentManageUnknownAppSources);
ArgumentCaptor<DialogInterface.OnClickListener> clickListener = ArgumentCaptor.forClass(DialogInterface.OnClickListener.class);
verify(mDialogBuilder).setPositiveButton(eq(R.string.appcenter_distribute_unknown_sources_dialog_settings), clickListener.capture());
/* Verify behaviour on old version. */
TestUtils.setInternalState(Build.VERSION.class, "SDK_INT", BuildConfig.MIN_SDK_VERSION);
clickListener.getValue().onClick(mUnknownSourcesDialog, DialogInterface.BUTTON_POSITIVE);
verify(mFirstActivity).startActivity(intentSecuritySettings);
verify(mFirstActivity, never()).startActivity(intentManageUnknownAppSources);
reset(mFirstActivity);
/* Verify behaviour on Android O. */
TestUtils.setInternalState(Build.VERSION.class, "SDK_INT", Build.VERSION_CODES.O);
clickListener.getValue().onClick(mUnknownSourcesDialog, DialogInterface.BUTTON_POSITIVE);
verify(mFirstActivity, never()).startActivity(intentSecuritySettings);
verify(mFirstActivity).startActivity(intentManageUnknownAppSources);
}
use of org.powermock.core.classloader.annotations.PrepareForTest in project mobile-center-sdk-android by Microsoft.
the class CrashesTest method minidumpDeviceUserIdNotNull.
@Test
@PrepareForTest({ SessionContext.class, DeviceInfoHelper.class })
public void minidumpDeviceUserIdNotNull() throws Exception {
long appStartTime = 95000L;
long crashTime = 126000L;
ManagedErrorLog crashLog = testNativeCrashLog(appStartTime, crashTime, true, false, true);
assertNotNull(crashLog.getUserId());
}
use of org.powermock.core.classloader.annotations.PrepareForTest in project mobile-center-sdk-android by Microsoft.
the class CrashesTest method minidumpAppLaunchTimestampFromSessionContext.
@Test
@PrepareForTest({ SessionContext.class, DeviceInfoHelper.class })
public void minidumpAppLaunchTimestampFromSessionContext() throws Exception {
long appStartTime = 99000L;
long crashTime = 123000L;
ManagedErrorLog crashLog = testNativeCrashLog(appStartTime, crashTime, true, true, true);
assertEquals(new Date(crashTime), crashLog.getTimestamp());
assertEquals(new Date(appStartTime), crashLog.getAppLaunchTimestamp());
}
use of org.powermock.core.classloader.annotations.PrepareForTest in project mobile-center-sdk-android by Microsoft.
the class CrashesTest method minidumpDeviceUserIdNull.
@Test
@PrepareForTest({ SessionContext.class, DeviceInfoHelper.class })
public void minidumpDeviceUserIdNull() throws Exception {
long appStartTime = 95000L;
long crashTime = 126000L;
ManagedErrorLog crashLog = testNativeCrashLog(appStartTime, crashTime, true, false, false);
assertNull(crashLog.getUserId());
}
use of org.powermock.core.classloader.annotations.PrepareForTest in project mobile-center-sdk-android by Microsoft.
the class CrashesTest method minidumpDeviceInfoNull.
@Test
@PrepareForTest({ SessionContext.class, DeviceInfoHelper.class })
public void minidumpDeviceInfoNull() throws Exception {
long appStartTime = 95000L;
long crashTime = 126000L;
ManagedErrorLog crashLog = testNativeCrashLog(appStartTime, crashTime, true, false, false);
assertEquals(new Date(crashTime), crashLog.getTimestamp());
assertEquals(new Date(appStartTime), crashLog.getAppLaunchTimestamp());
}
Aggregations