當前位置: 首頁>>代碼示例>>Java>>正文


Java ShadowLog.LogItem方法代碼示例

本文整理匯總了Java中org.robolectric.shadows.ShadowLog.LogItem方法的典型用法代碼示例。如果您正苦於以下問題:Java ShadowLog.LogItem方法的具體用法?Java ShadowLog.LogItem怎麽用?Java ShadowLog.LogItem使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在org.robolectric.shadows.ShadowLog的用法示例。


在下文中一共展示了ShadowLog.LogItem方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: loadPositions_withNoConnection_shouldLogMoPubErrorCodeNoConnection_shouldCallFailureHandler

import org.robolectric.shadows.ShadowLog; //導入方法依賴的package包/類
@Test
public void loadPositions_withNoConnection_shouldLogMoPubErrorCodeNoConnection_shouldCallFailureHandler() {
    MoPubLog.setSdkHandlerLevel(Level.ALL);

    when(mockContext.checkCallingOrSelfPermission(anyString()))
            .thenReturn(PackageManager.PERMISSION_DENIED);
    when(spyActivity.getApplicationContext()).thenReturn(mockContext);
    // Reinit the subject so we get our mocked context.
    subject = new ServerPositioningSource(spyActivity);

    // Simulate failure after max time.
    subject.setMaximumRetryTimeMilliseconds(999);
    subject.loadPositions("test_ad_unit", mockPositioningListener);

    verify(mockRequestQueue).add(positionRequestCaptor.capture());
    positionRequestCaptor.getValue().deliverError(new NoConnectionError());

    verify(mockPositioningListener).onFailed();

    final List<ShadowLog.LogItem> allLogMessages = ShadowLog.getLogs();
    final ShadowLog.LogItem latestLogMessage = allLogMessages.get(allLogMessages.size() - 2);
    // All log messages end with a newline character.
    assertThat(latestLogMessage.msg.trim()).isEqualTo(MoPubErrorCode.NO_CONNECTION.toString());
}
 
開發者ID:JSafaiyeh,項目名稱:Fabric-Example-App-Android,代碼行數:25,代碼來源:ServerPositioningSourceTest.java

示例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"
    );
}
 
開發者ID:JSafaiyeh,項目名稱:Fabric-Example-App-Android,代碼行數:17,代碼來源:ManifestUtilsTest.java

示例3: log

import org.robolectric.shadows.ShadowLog; //導入方法依賴的package包/類
@Test public void log() {
  LogStrategy logStrategy = new LogcatLogStrategy();

  logStrategy.log(DEBUG, "tag", "message");

  List<ShadowLog.LogItem> logItems = ShadowLog.getLogs();
  assertThat(logItems.get(0).type).isEqualTo(DEBUG);
  assertThat(logItems.get(0).msg).isEqualTo("message");
  assertThat(logItems.get(0).tag).isEqualTo("tag");
}
 
開發者ID:weiwenqiang,項目名稱:GitHub,代碼行數:11,代碼來源:LogcatLogStrategyTest.java

示例4: callOriginTest

import org.robolectric.shadows.ShadowLog; //導入方法依賴的package包/類
/** Tests that the computed call origin is the correct one. */
@Test
public void callOriginTest() {
    Log.d("Foo", "Bar");

    List<ShadowLog.LogItem> logs = ShadowLog.getLogs();
    assertEquals("Only one log should be written", 1, logs.size());

    assertTrue("The origin of the log message (" + logs.get(0).msg + ") looks wrong.",
            logs.get(0).msg.matches("\\[LogTest.java:\\d+\\].*"));
}
 
開發者ID:lizhangqu,項目名稱:chromium-net-for-android,代碼行數:12,代碼來源:LogTest.java

示例5: exceptionLoggingTest

import org.robolectric.shadows.ShadowLog; //導入方法依賴的package包/類
/** Tests that exceptions provided to the log functions are properly recognized and printed. */
@Test
public void exceptionLoggingTest() {
    Throwable t = new Throwable() {
        @Override
        public String toString() {
            return "MyThrowable";
        }
    };

    Throwable t2 = new Throwable() {
        @Override
        public String toString() {
            return "MyOtherThrowable";
        }
    };

    List<ShadowLog.LogItem> logs = ShadowLog.getLogs();

    // The throwable gets printed out
    Log.i("Foo", "Bar", t);
    assertEquals(t, logs.get(logs.size() - 1).throwable);
    assertEquals("Bar", logs.get(logs.size() - 1).msg);

    // The throwable can be both added to the message itself and printed out
    Log.i("Foo", "Bar %s", t);
    assertEquals(t, logs.get(logs.size() - 1).throwable);
    assertEquals("Bar MyThrowable", logs.get(logs.size() - 1).msg);

    // Non throwable are properly identified
    Log.i("Foo", "Bar %s", t, "Baz");
    assertNull(logs.get(logs.size() - 1).throwable);
    assertEquals("Bar MyThrowable", logs.get(logs.size() - 1).msg);

    // The last throwable is the one used that is going to be printed out
    Log.i("Foo", "Bar %s %s", t, t2);
    assertEquals(t2, logs.get(logs.size() - 1).throwable);
    assertEquals("Bar MyThrowable MyOtherThrowable", logs.get(logs.size() - 1).msg);
}
 
開發者ID:lizhangqu,項目名稱:chromium-net-for-android,代碼行數:40,代碼來源:LogTest.java

示例6: onAdError_withVolleyErrorWarmingUp_shouldLogMoPubErrorCodeWarmup_shouldNotifyListener

import org.robolectric.shadows.ShadowLog; //導入方法依賴的package包/類
@Test
public void onAdError_withVolleyErrorWarmingUp_shouldLogMoPubErrorCodeWarmup_shouldNotifyListener() {
    MoPubLog.setSdkHandlerLevel(Level.ALL);

    subject.onAdError(new MoPubNetworkError(MoPubNetworkError.Reason.WARMING_UP));

    final List<ShadowLog.LogItem> allLogMessages = ShadowLog.getLogs();
    final ShadowLog.LogItem latestLogMessage = allLogMessages.get(allLogMessages.size() - 1);

    // All log messages end with a newline character.
    assertThat(latestLogMessage.msg.trim()).isEqualTo(MoPubErrorCode.WARMUP.toString());
    verify(mockNetworkListener).onNativeFail(eq(NativeErrorCode.EMPTY_AD_RESPONSE));
}
 
開發者ID:JSafaiyeh,項目名稱:Fabric-Example-App-Android,代碼行數:14,代碼來源:MoPubNativeTest.java

示例7: onAdError_withNoConnection_shouldLogMoPubErrorCodeNoConnection_shouldNotifyListener

import org.robolectric.shadows.ShadowLog; //導入方法依賴的package包/類
@Test
public void onAdError_withNoConnection_shouldLogMoPubErrorCodeNoConnection_shouldNotifyListener() {
    MoPubLog.setSdkHandlerLevel(Level.ALL);
    shadowOf(context).denyPermissions(INTERNET);

    subject.onAdError(new NoConnectionError());

    final List<ShadowLog.LogItem> allLogMessages = ShadowLog.getLogs();
    final ShadowLog.LogItem latestLogMessage = allLogMessages.get(allLogMessages.size() - 1);

    // All log messages end with a newline character.
    assertThat(latestLogMessage.msg.trim()).isEqualTo(MoPubErrorCode.NO_CONNECTION.toString());
    verify(mockNetworkListener).onNativeFail(eq(NativeErrorCode.CONNECTION_ERROR));
}
 
開發者ID:JSafaiyeh,項目名稱:Fabric-Example-App-Android,代碼行數:15,代碼來源:MoPubNativeTest.java

示例8: assertLogged

import org.robolectric.shadows.ShadowLog; //導入方法依賴的package包/類
public static void assertLogged(int type, String tag, String msg, Throwable throwable) {
  ShadowLog.LogItem lastLog = ShadowLog.getLogs().get(0);
  assertThat(type).isEqualTo(lastLog.type);
  assertThat(msg).isEqualTo(lastLog.msg);
  assertThat(tag).isEqualTo(lastLog.tag);
  assertThat(throwable).isEqualTo(lastLog.throwable);
}
 
開發者ID:devinciltd,項目名稱:lib,代碼行數:8,代碼來源:Assertions.java

示例9: assertLogged

import org.robolectric.shadows.ShadowLog; //導入方法依賴的package包/類
private void assertLogged(int type, String tag, String msg, Throwable throwable) {
    ShadowLog.LogItem lastLog = ShadowLog.getLogs().get(0);
    assertEquals(type, lastLog.type);
    assertEquals(msg, lastLog.msg);
    assertEquals(tag, lastLog.tag);
    assertEquals(throwable, lastLog.throwable);
}
 
開發者ID:AltBeacon,項目名稱:android-beacon-library,代碼行數:8,代碼來源:VerboseAndroidLoggerTest.java

示例10: shouldLog_activity

import org.robolectric.shadows.ShadowLog; //導入方法依賴的package包/類
@Test
public void shouldLog_activity() {
  Robolectric.buildActivity(TestActivity.class).create().start().stop().destroy().get();
  List<ShadowLog.LogItem> logItems = ShadowLog.getLogsForTag("LogLifeCycle");

  assertNotNull(logItems);
  assertLogContainsMessage(logItems, "onCreate");
  assertLogContainsMessage(logItems, "onStart");
  assertLogContainsMessage(logItems, "onStop");
  assertLogContainsMessage(logItems, "onDestroy");
}
 
開發者ID:stephanenicolas,項目名稱:loglifecycle,代碼行數:12,代碼來源:LogLifeCycleProcessorTest.java

示例11: shouldLog_fragment

import org.robolectric.shadows.ShadowLog; //導入方法依賴的package包/類
@Test
public void shouldLog_fragment() {
  Robolectric.buildActivity(TestActivityWitFragment.class).create().start().stop().destroy().get();
  List<ShadowLog.LogItem> logItems = ShadowLog.getLogsForTag("LogLifeCycle");

  assertNotNull(logItems);
  assertLogContainsMessage(logItems, "onStart");
  assertLogContainsMessage(logItems, "onStop");
}
 
開發者ID:stephanenicolas,項目名稱:loglifecycle,代碼行數:10,代碼來源:LogLifeCycleProcessorTest.java

示例12: shouldLog_View

import org.robolectric.shadows.ShadowLog; //導入方法依賴的package包/類
@Test
public void shouldLog_View() {
  Robolectric.buildActivity(TestActivityWitView.class).create().start().get();
  List<ShadowLog.LogItem> logItems = ShadowLog.getLogsForTag("LogLifeCycle");

  assertNotNull(logItems);
  assertLogContainsMessage(logItems, "onFinishInflate");
}
 
開發者ID:stephanenicolas,項目名稱:loglifecycle,代碼行數:9,代碼來源:LogLifeCycleProcessorTest.java

示例13: shouldLog_Service

import org.robolectric.shadows.ShadowLog; //導入方法依賴的package包/類
@Test
public void shouldLog_Service() {
  Robolectric.buildService(TestService.class).attach().create().withIntent(null).startCommand(0,1).destroy().get();
  List<ShadowLog.LogItem> logItems = ShadowLog.getLogsForTag("LogLifeCycle");

  assertNotNull(logItems);
  assertLogContainsMessage(logItems, "onCreate");
  assertLogContainsMessage(logItems, "onStart");
  assertLogContainsMessage(logItems, "onDestroy");
}
 
開發者ID:stephanenicolas,項目名稱:loglifecycle,代碼行數:11,代碼來源:LogLifeCycleProcessorTest.java

示例14: assertLogContainsMessage

import org.robolectric.shadows.ShadowLog; //導入方法依賴的package包/類
private void assertLogContainsMessage(List<ShadowLog.LogItem> logItems, String logMessage) {
  for(ShadowLog.LogItem logItem : logItems ) {
    if (logItem.msg.contains(logMessage)) {
      return;
    }
  }
  fail("No message " + logMessage + " in log");
}
 
開發者ID:stephanenicolas,項目名稱:loglifecycle,代碼行數:9,代碼來源:LogLifeCycleProcessorTest.java

示例15: setSearchResults_shouldCheckForNullPager

import org.robolectric.shadows.ShadowLog; //導入方法依賴的package包/類
@Test
public void setSearchResults_shouldCheckForNullPager() throws Exception {
    ArrayList<Feature> features = new ArrayList<Feature>();
    features.add(getTestFeature());
    fragment.pager = null;
    fragment.setSearchResults(features);
    List<ShadowLog.LogItem> logs = ShadowLog.getLogs();
    assertThat(logs.get(logs.size() - 1).msg)
            .isEqualTo("Unable to display search results: pager is null");
}
 
開發者ID:mapzen,項目名稱:open,代碼行數:11,代碼來源:PagerResultsFragmentTest.java


注:本文中的org.robolectric.shadows.ShadowLog.LogItem方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。