Java Code Examples for org.robolectric.shadows.ShadowLog#getLogs()
The following examples show how to use
org.robolectric.shadows.ShadowLog#getLogs() .
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: TimberTest.java From Utils with Apache License 2.0 | 5 votes |
private static void assertExceptionLogged(String message, String exceptionClassname) { List<LogItem> logs = ShadowLog.getLogs(); assertThat(logs).hasSize(1); LogItem log = logs.get(0); assertThat(log.type).isEqualTo(Log.ERROR); assertThat(log.tag).isEqualTo("TimberTest"); assertThat(log.msg).startsWith(message); assertThat(log.msg).contains(exceptionClassname); // We use a low-level primitive that Robolectric doesn't populate. assertThat(log.throwable).isNull(); }
Example 2
Source File: VerboseAndroidLoggerTest.java From android-beacon-library with Apache License 2.0 | 5 votes |
private void assertLogged(int type, String tag, String msg, Throwable throwable) { List<ShadowLog.LogItem> logs = ShadowLog.getLogs(); ShadowLog.LogItem lastLog = logs.get(logs.size() - 1); assertEquals(type, lastLog.type); assertEquals(msg, lastLog.msg); assertEquals(tag, lastLog.tag); assertEquals(throwable, lastLog.throwable); }
Example 3
Source File: WarningAndroidLoggerTest.java From android-beacon-library with Apache License 2.0 | 5 votes |
private void assertLogged(int type, String tag, String msg, Throwable throwable) { List<ShadowLog.LogItem> logs = ShadowLog.getLogs(); ShadowLog.LogItem lastLog = logs.get(logs.size() - 1); assertEquals(type, lastLog.type); assertEquals(msg, lastLog.msg); assertEquals(tag, lastLog.tag); assertEquals(throwable, lastLog.throwable); }
Example 4
Source File: WarningAndroidLoggerTest.java From android-beacon-library with Apache License 2.0 | 5 votes |
private void assertNotLogged() { final List<ShadowLog.LogItem> logs = ShadowLog.getLogs(); for (ShadowLog.LogItem log : logs) { //INFO level log was introduced by ASOP //https://android.googlesource.com/platform/frameworks/base/+/master/core/java/android/content/res/AssetManager.java assertThat(log.type, isOneOf(Log.INFO, Log.WARN, Log.ERROR)); } }
Example 5
Source File: PagerResultsFragmentTest.java From open with GNU General Public License v3.0 | 5 votes |
@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"); }
Example 6
Source File: TimberTest.java From Utils with Apache License 2.0 | 4 votes |
private static LogAssert assertLog() { return new LogAssert(ShadowLog.getLogs()); }