Java Code Examples for org.robolectric.shadows.ShadowLog#getLogsForTag()

The following examples show how to use org.robolectric.shadows.ShadowLog#getLogsForTag() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: GeoJSONUtilTest.java    From appinventor-extensions with Apache License 2.0 5 votes vote down vote up
public void testProcessGeoJSONWarnUnknownProperty() {
  ShadowLog.setupLogging();
  GeoJSONUtil.processGeoJSONFeature(LOG_TAG, getMap(),
      alist("type", "Feature",
          "FooBar", false,
          "geometry", alist("type", "Point", "coordinates", list(-71, 42))));

  // Check that the FooBar property triggers a warning message
  List<LogItem> logs = ShadowLog.getLogsForTag(LOG_TAG);
  assertEquals(1, logs.size());
  assertEquals("Unsupported field \"FooBar\" in JSON format", logs.get(0).msg);
}
 
Example 2
Source File: SnackbarCallbackTest.java    From SnackbarBuilder with Apache License 2.0 5 votes vote down vote up
@Test
public void whenOnSnackbarShown_twhenSnackbarShownMessageLogged() {
  callbackUnderTest.onSnackbarShown(snackbar);

  List<LogItem> logs = ShadowLog.getLogsForTag(SnackbarCallback.class.getSimpleName());
  assertThat(logs).hasSize(1);
  assertThat(logs.get(0).msg).isEqualTo("onSnackbarShown");
}
 
Example 3
Source File: SnackbarCallbackTest.java    From SnackbarBuilder with Apache License 2.0 5 votes vote down vote up
@Test
public void whenOnSnackbarDismissed_thenSnackbarDismissedMessageLogged() {
  callbackUnderTest.onSnackbarDismissed(snackbar);

  List<LogItem> logs = ShadowLog.getLogsForTag(SnackbarCallback.class.getSimpleName());
  assertThat(logs).hasSize(1);
  assertThat(logs.get(0).msg).isEqualTo("onSnackbarDismissed");
}
 
Example 4
Source File: SnackbarCallbackTest.java    From SnackbarBuilder with Apache License 2.0 5 votes vote down vote up
@Test
public void whenOnSnackbarDismissedWithEventType_thenSnackbarDismissedMessageLogged() {
  callbackUnderTest.onSnackbarDismissed(snackbar, Callback.DISMISS_EVENT_TIMEOUT);

  List<LogItem> logs = ShadowLog.getLogsForTag(SnackbarCallback.class.getSimpleName());
  assertThat(logs).hasSize(1);
  assertThat(logs.get(0).msg).isEqualTo("onSnackbarDismissed method = 2");
}
 
Example 5
Source File: SnackbarCallbackTest.java    From SnackbarBuilder with Apache License 2.0 5 votes vote down vote up
@Test
public void whenOnSnackbarActionPressed_thenSnackbarActionPressedMessageLogged() {
  callbackUnderTest.onSnackbarActionPressed(snackbar);

  List<LogItem> logs = ShadowLog.getLogsForTag(SnackbarCallback.class.getSimpleName());
  assertThat(logs).hasSize(1);
  assertThat(logs.get(0).msg).isEqualTo("onSnackbarActionPressed");
}
 
Example 6
Source File: SnackbarCallbackTest.java    From SnackbarBuilder with Apache License 2.0 5 votes vote down vote up
@Test
public void whenOnSnackbarSwiped_thenSnackbarSwipedMessageLogged() {
  callbackUnderTest.onSnackbarSwiped(snackbar);

  List<LogItem> logs = ShadowLog.getLogsForTag(SnackbarCallback.class.getSimpleName());
  assertThat(logs).hasSize(1);
  assertThat(logs.get(0).msg).isEqualTo("onSnackbarSwiped");
}
 
Example 7
Source File: SnackbarCallbackTest.java    From SnackbarBuilder with Apache License 2.0 5 votes vote down vote up
@Test
public void whenOnSnackbarTimedOut_thenSnackbarTimedOutMessageLogged() {
  callbackUnderTest.onSnackbarTimedOut(snackbar);

  List<LogItem> logs = ShadowLog.getLogsForTag(SnackbarCallback.class.getSimpleName());
  assertThat(logs).hasSize(1);
  assertThat(logs.get(0).msg).isEqualTo("onSnackbarTimedOut");
}
 
Example 8
Source File: SnackbarCallbackTest.java    From SnackbarBuilder with Apache License 2.0 5 votes vote down vote up
@Test
public void whenOnSnackbarManuallyDismissed_thenSnackbarManuallyDismissedMessageLogged() {
  callbackUnderTest.onSnackbarManuallyDismissed(snackbar);

  List<LogItem> logs = ShadowLog.getLogsForTag(SnackbarCallback.class.getSimpleName());
  assertThat(logs).hasSize(1);
  assertThat(logs.get(0).msg).isEqualTo("onSnackbarManuallyDismissed");
}
 
Example 9
Source File: SnackbarCallbackTest.java    From SnackbarBuilder with Apache License 2.0 5 votes vote down vote up
@Test
public void whenOnSnackbarDismissedAfterAnotherShown_thenSnackbarDismissedAfterAnotherShownMessageLogged() {
  callbackUnderTest.onSnackbarDismissedAfterAnotherShown(snackbar);

  List<LogItem> logs = ShadowLog.getLogsForTag(SnackbarCallback.class.getSimpleName());
  assertThat(logs).hasSize(1);
  assertThat(logs.get(0).msg).isEqualTo("onSnackbarDismissedAfterAnotherShown");
}
 
Example 10
Source File: LogLifeCycleProcessorTest.java    From loglifecycle with Apache License 2.0 5 votes vote down vote up
@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");
}
 
Example 11
Source File: LogLifeCycleProcessorTest.java    From loglifecycle with Apache License 2.0 5 votes vote down vote up
@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");
}
 
Example 12
Source File: LogLifeCycleProcessorTest.java    From loglifecycle with Apache License 2.0 5 votes vote down vote up
@Test
public void shouldLog_View() {
  Robolectric.buildActivity(TestActivityWitView.class).create().start().get();
  List<ShadowLog.LogItem> logItems = ShadowLog.getLogsForTag("LogLifeCycle");

  assertNotNull(logItems);
  assertLogContainsMessage(logItems, "onFinishInflate");
}
 
Example 13
Source File: LogLifeCycleProcessorTest.java    From loglifecycle with Apache License 2.0 5 votes vote down vote up
@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");
}
 
Example 14
Source File: GeoJSONUtilTest.java    From appinventor-extensions with Apache License 2.0 4 votes vote down vote up
private static void assertLogTriggered() {
  // Check that the triggersLog property triggers a log message
  List<LogItem> logs = ShadowLog.getLogsForTag(LOG_TAG);
  assertEquals(1, logs.size());
  assertEquals("Ignoring GeoJSON property \"triggersLog\"", logs.get(0).msg);
}
 
Example 15
Source File: LegacyUriRedirectHandlerTest.java    From rides-android-sdk with MIT License 4 votes vote down vote up
private void assertLastLog(String message) {
    List<ShadowLog.LogItem> logItemList = ShadowLog.getLogsForTag(UberSdk.UBER_SDK_LOG_TAG);
    assertThat(ShadowLog.getLogsForTag(UberSdk.UBER_SDK_LOG_TAG)).isNotEmpty();
    ShadowLog.LogItem logItem = logItemList.get(logItemList.size()-1);
    assertThat(logItem.msg).isEqualTo(message);
}
 
Example 16
Source File: LegacyUriRedirectHandlerTest.java    From rides-android-sdk with MIT License 4 votes vote down vote up
private void assertNoLogs() {
    List<ShadowLog.LogItem> logItemList = ShadowLog.getLogsForTag(UberSdk.UBER_SDK_LOG_TAG);
    assertThat(ShadowLog.getLogsForTag(UberSdk.UBER_SDK_LOG_TAG)).isNull();
}