本文整理匯總了Java中org.robolectric.shadows.ShadowLog.setupLogging方法的典型用法代碼示例。如果您正苦於以下問題:Java ShadowLog.setupLogging方法的具體用法?Java ShadowLog.setupLogging怎麽用?Java ShadowLog.setupLogging使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.robolectric.shadows.ShadowLog
的用法示例。
在下文中一共展示了ShadowLog.setupLogging方法的10個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: displayWarningForMissingActivities_withOneMissingActivity_shouldLogOnlyThatOne
import org.robolectric.shadows.ShadowLog; //導入方法依賴的package包/類
@Test
public void displayWarningForMissingActivities_withOneMissingActivity_shouldLogOnlyThatOne() throws Exception {
Robolectric.packageManager.addResolveInfoForIntent(new Intent(context, MoPubActivity.class), mockResolveInfo);
Robolectric.packageManager.addResolveInfoForIntent(new Intent(context, MraidActivity.class), mockResolveInfo);
Robolectric.packageManager.addResolveInfoForIntent(new Intent(context, MraidVideoPlayerActivity.class), mockResolveInfo);
// Here, we leave out MoPubBrowser on purpose
ShadowLog.setupLogging();
ManifestUtils.displayWarningForMissingActivities(context, requiredWebViewSdkActivities);
assertLogIncludes("com.mopub.common.MoPubBrowser");
assertLogDoesntInclude(
"com.mopub.mobileads.MoPubActivity",
"com.mopub.mobileads.MraidActivity",
"com.mopub.mobileads.MraidVideoPlayerActivity"
);
}
示例2: displayWarningForMissingActivities_withAllMissingActivities_shouldLogMessage
import org.robolectric.shadows.ShadowLog; //導入方法依賴的package包/類
@Test
public void displayWarningForMissingActivities_withAllMissingActivities_shouldLogMessage() throws Exception {
setDebugMode(true);
ShadowLog.setupLogging();
ManifestUtils.displayWarningForMissingActivities(context, requiredWebViewSdkActivities);
final List<ShadowLog.LogItem> logs = ShadowLog.getLogs();
assertLogIncludes(
"com.mopub.mobileads.MoPubActivity",
"com.mopub.mobileads.MraidActivity",
"com.mopub.mobileads.MraidVideoPlayerActivity",
"com.mopub.common.MoPubBrowser"
);
}
示例3: displayWarningForMisconfiguredActivities_withAllActivitiesConfigured_shouldNotLogOrShowToast
import org.robolectric.shadows.ShadowLog; //導入方法依賴的package包/類
@SuppressWarnings("unchecked")
@TargetApi(13)
@Test
public void displayWarningForMisconfiguredActivities_withAllActivitiesConfigured_shouldNotLogOrShowToast() throws Exception {
ManifestUtils.FlagCheckUtil mockActivitiyConfigCheck = mock(ManifestUtils.FlagCheckUtil.class);
when(mockActivitiyConfigCheck.hasFlag(any(Class.class), anyInt(), eq(ActivityInfo.CONFIG_KEYBOARD_HIDDEN))).thenReturn(true);
when(mockActivitiyConfigCheck.hasFlag(any(Class.class), anyInt(), eq(ActivityInfo.CONFIG_ORIENTATION))).thenReturn(true);
when(mockActivitiyConfigCheck.hasFlag(any(Class.class), anyInt(), eq(ActivityInfo.CONFIG_SCREEN_SIZE))).thenReturn(true);
ManifestUtils.setFlagCheckUtil(mockActivitiyConfigCheck);
Robolectric.packageManager.addResolveInfoForIntent(new Intent(context, MoPubActivity.class), mockResolveInfo);
Robolectric.packageManager.addResolveInfoForIntent(new Intent(context, MraidActivity.class), mockResolveInfo);
Robolectric.packageManager.addResolveInfoForIntent(new Intent(context, MraidVideoPlayerActivity.class), mockResolveInfo);
Robolectric.packageManager.addResolveInfoForIntent(new Intent(context, MoPubBrowser.class), mockResolveInfo);
ShadowLog.setupLogging();
setDebugMode(true);
ManifestUtils.displayWarningForMisconfiguredActivities(context, requiredWebViewSdkActivities);
assertThat(ShadowToast.getLatestToast()).isNull();
assertThat(ShadowLog.getLogs()).isEmpty();
}
示例4: mock
import org.robolectric.shadows.ShadowLog; //導入方法依賴的package包/類
@SuppressWarnings("unchecked")
@TargetApi(13)
@Test
public void displayWarningForMisconfiguredActivities_withOneMisconfiguredActivity_withMissingAllConfigChangesValues_shouldLogAllConfigChangesValues() throws Exception {
ManifestUtils.FlagCheckUtil mockActivitiyConfigCheck = mock(ManifestUtils.FlagCheckUtil.class);
when(mockActivitiyConfigCheck.hasFlag(any(Class.class), anyInt(), eq(ActivityInfo.CONFIG_KEYBOARD_HIDDEN))).thenReturn(false);
when(mockActivitiyConfigCheck.hasFlag(any(Class.class), anyInt(), eq(ActivityInfo.CONFIG_ORIENTATION))).thenReturn(false);
when(mockActivitiyConfigCheck.hasFlag(any(Class.class), anyInt(), eq(ActivityInfo.CONFIG_SCREEN_SIZE))).thenReturn(false);
ManifestUtils.setFlagCheckUtil(mockActivitiyConfigCheck);
Robolectric.packageManager.addResolveInfoForIntent(new Intent(context, MoPubActivity.class), mockResolveInfo);
ShadowLog.setupLogging();
ManifestUtils.displayWarningForMisconfiguredActivities(context, requiredWebViewSdkActivities);
assertLogIncludes("The android:configChanges param for activity " + MoPubActivity.class.getName() + " must include keyboardHidden.");
assertLogIncludes("The android:configChanges param for activity " + MoPubActivity.class.getName() + " must include orientation.");
assertLogIncludes("The android:configChanges param for activity " + MoPubActivity.class.getName() + " must include screenSize.");
}
示例5: when
import org.robolectric.shadows.ShadowLog; //導入方法依賴的package包/類
@SuppressWarnings("unchecked")
@TargetApi(13)
@Test
public void displayWarningForMisconfiguredActivities_withMissingScreenSize_withTargetApiLessThan13_shouldNotLogOrShowToast() throws Exception {
// Set target API to < 13
ApplicationInfo applicationInfo = context.getApplicationInfo();
applicationInfo.targetSdkVersion = Build.VERSION_CODES.HONEYCOMB_MR1;
when(context.getApplicationInfo()).thenReturn(applicationInfo);
ManifestUtils.FlagCheckUtil mockActivitiyConfigCheck = mock(ManifestUtils.FlagCheckUtil.class);
when(mockActivitiyConfigCheck.hasFlag(any(Class.class), anyInt(), eq(ActivityInfo.CONFIG_KEYBOARD_HIDDEN))).thenReturn(true);
when(mockActivitiyConfigCheck.hasFlag(any(Class.class), anyInt(), eq(ActivityInfo.CONFIG_ORIENTATION))).thenReturn(true);
when(mockActivitiyConfigCheck.hasFlag(any(Class.class), anyInt(), eq(ActivityInfo.CONFIG_SCREEN_SIZE))).thenReturn(false);
ManifestUtils.setFlagCheckUtil(mockActivitiyConfigCheck);
Robolectric.packageManager.addResolveInfoForIntent(new Intent(context, MoPubActivity.class), mockResolveInfo);
ShadowLog.setupLogging();
setDebugMode(true);
ManifestUtils.displayWarningForMisconfiguredActivities(context, requiredWebViewSdkActivities);
assertThat(ShadowToast.getLatestToast()).isNull();
assertThat(ShadowLog.getLogs()).isEmpty();
}
示例6: checkWebViewSdkActivitiesDeclared_shouldIncludeFourActivityDeclarations
import org.robolectric.shadows.ShadowLog; //導入方法依賴的package包/類
@Test
public void checkWebViewSdkActivitiesDeclared_shouldIncludeFourActivityDeclarations() throws Exception {
ShadowLog.setupLogging();
ManifestUtils.checkWebViewActivitiesDeclared(context);
assertLogIncludes(
"com.mopub.mobileads.MoPubActivity",
"com.mopub.mobileads.MraidActivity",
"com.mopub.mobileads.MraidVideoPlayerActivity",
"com.mopub.common.MoPubBrowser"
);
}
示例7: checkNativeSdkActivitiesDeclared_shouldIncludeOneActivityDeclaration
import org.robolectric.shadows.ShadowLog; //導入方法依賴的package包/類
@Test
public void checkNativeSdkActivitiesDeclared_shouldIncludeOneActivityDeclaration() throws Exception {
ShadowLog.setupLogging();
ManifestUtils.checkNativeActivitiesDeclared(context);
assertLogIncludes("com.mopub.common.MoPubBrowser");
assertLogDoesntInclude(
"com.mopub.mobileads.MoPubActivity",
"com.mopub.mobileads.MraidActivity",
"com.mopub.mobileads.MraidVideoPlayerActivity"
);
}
示例8: displayWarningForMissingActivities_withAllActivitiesDeclared_shouldNotShowLogOrToast
import org.robolectric.shadows.ShadowLog; //導入方法依賴的package包/類
@Test
public void displayWarningForMissingActivities_withAllActivitiesDeclared_shouldNotShowLogOrToast() throws Exception {
Robolectric.packageManager.addResolveInfoForIntent(new Intent(context, MoPubActivity.class), mockResolveInfo);
Robolectric.packageManager.addResolveInfoForIntent(new Intent(context, MraidActivity.class), mockResolveInfo);
Robolectric.packageManager.addResolveInfoForIntent(new Intent(context, MraidVideoPlayerActivity.class), mockResolveInfo);
Robolectric.packageManager.addResolveInfoForIntent(new Intent(context, MoPubBrowser.class), mockResolveInfo);
ShadowLog.setupLogging();
setDebugMode(true);
ManifestUtils.displayWarningForMissingActivities(context, requiredWebViewSdkActivities);
assertThat(ShadowToast.getLatestToast()).isNull();
assertThat(ShadowLog.getLogs()).isEmpty();
}
示例9: displayWarningForMisconfiguredActivities_withOneMisconfiguredActivity_shouldLogOnlyThatOne
import org.robolectric.shadows.ShadowLog; //導入方法依賴的package包/類
@SuppressWarnings("unchecked")
@TargetApi(13)
@Test
public void displayWarningForMisconfiguredActivities_withOneMisconfiguredActivity_shouldLogOnlyThatOne() throws Exception {
ManifestUtils.FlagCheckUtil mockActivitiyConfigCheck = mock(ManifestUtils.FlagCheckUtil.class);
// Misconfigure the first activity; only return false if the activity is MoPubActivity
doAnswer(new Answer() {
@Override
public Object answer(InvocationOnMock invocationOnMock) throws Throwable {
Object[] args = invocationOnMock.getArguments();
return MoPubActivity.class != args[0];
}
}).when(mockActivitiyConfigCheck).hasFlag(any(Class.class), anyInt(), eq(ActivityInfo.CONFIG_KEYBOARD_HIDDEN));
when(mockActivitiyConfigCheck.hasFlag(any(Class.class), anyInt(), eq(ActivityInfo.CONFIG_ORIENTATION))).thenReturn(true);
when(mockActivitiyConfigCheck.hasFlag(any(Class.class), anyInt(), eq(ActivityInfo.CONFIG_SCREEN_SIZE))).thenReturn(true);
ManifestUtils.setFlagCheckUtil(mockActivitiyConfigCheck);
Robolectric.packageManager.addResolveInfoForIntent(new Intent(context, MoPubActivity.class), mockResolveInfo);
Robolectric.packageManager.addResolveInfoForIntent(new Intent(context, MraidActivity.class), mockResolveInfo);
Robolectric.packageManager.addResolveInfoForIntent(new Intent(context, MraidVideoPlayerActivity.class), mockResolveInfo);
Robolectric.packageManager.addResolveInfoForIntent(new Intent(context, MoPubBrowser.class), mockResolveInfo);
ShadowLog.setupLogging();
ManifestUtils.displayWarningForMisconfiguredActivities(context, requiredWebViewSdkActivities);
assertLogIncludes("com.mopub.mobileads.MoPubActivity");
assertLogIncludes("The android:configChanges param for activity " + MoPubActivity.class.getName() + " must include keyboardHidden.");
assertLogDoesntInclude(
"com.mopub.mobileads.MraidActivity",
"com.mopub.mobileads.MraidVideoPlayerActivity",
"com.mopub.common.MoPubBrowser"
);
assertLogDoesntInclude("The android:configChanges param for activity " + MoPubActivity.class.getName() + " must include orientation.");
assertLogDoesntInclude("The android:configChanges param for activity " + MoPubActivity.class.getName() + " must include screenSize.");
}
示例10: resetStaticState
import org.robolectric.shadows.ShadowLog; //導入方法依賴的package包/類
@Override
public void resetStaticState(Config config) {
Robolectric.reset(config);
if (!loggingInitialized) {
ShadowLog.setupLogging();
loggingInitialized = true;
}
}