use of org.robolectric.shadows.ShadowLog.LogItem in project androidannotations by androidannotations.
the class TracedActivityTest method logContains.
/**
* Check if a message has been logged
*
* @param msg
* @return {@code true} if a log entry starting with {@code msg} exists
*/
private static boolean logContains(String msg) {
List<LogItem> logs = ShadowLog.getLogs();
boolean found = false;
for (LogItem logItem : logs) {
if (logItem.msg.startsWith(msg)) {
found = true;
}
}
return found;
}
use of org.robolectric.shadows.ShadowLog.LogItem in project robolectric by robolectric.
the class ShadowLogTest method assertUniformLogsForTag.
private static void assertUniformLogsForTag(String tag, int count) {
List<LogItem> tag1Items = ShadowLog.getLogsForTag(tag);
assertThat(tag1Items.size()).isEqualTo(count);
int last = -1;
for (LogItem item : tag1Items) {
assertThat(item.tag).isEqualTo(tag);
int current = Integer.parseInt(item.msg);
assertThat(current > last).isTrue();
last = current;
}
}
use of org.robolectric.shadows.ShadowLog.LogItem in project robolectric by robolectric.
the class ShadowLogTest method shouldLogAccordingToTag.
@Test
public void shouldLogAccordingToTag() throws Exception {
ShadowLog.reset();
Log.d("tag1", "1");
Log.i("tag2", "2");
Log.e("tag3", "3");
Log.w("tag1", "4");
Log.i("tag1", "5");
Log.d("tag2", "6");
Log.d("throwable", "7", specificMethodName());
List<LogItem> allItems = ShadowLog.getLogs();
assertThat(allItems.size()).isEqualTo(7);
int i = 1;
for (LogItem item : allItems) {
assertThat(item.msg).isEqualTo(Integer.toString(i));
assertThat(item.toString()).contains(item.msg);
i++;
}
assertThat(allItems.get(6).toString()).contains("specificMethodName");
assertUniformLogsForTag("tag1", 3);
assertUniformLogsForTag("tag2", 2);
assertUniformLogsForTag("tag3", 1);
}
use of org.robolectric.shadows.ShadowLog.LogItem in project robolectric by robolectric.
the class ShadowLogTest method assertLogged.
private static void assertLogged(String timeString, int type, String tag, String msg, Throwable throwable) {
LogItem lastLog = Iterables.getLast(ShadowLog.getLogsForTag(tag));
assertEquals(timeString, lastLog.timeString);
assertLogged(type, tag, msg, throwable);
}
Aggregations