Java Code Examples for org.robolectric.shadows.ShadowLog#LogItem
The following examples show how to use
org.robolectric.shadows.ShadowLog#LogItem .
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: AppStatesServiceTest.java From android-testdpc with Apache License 2.0 | 5 votes |
private void assertThatLogContainsRequiredInformation( ShadowLog.LogItem logItem, ReceivedKeyedAppState state) { assertThat(logItem.msg).contains(Long.toString(state.getTimestamp())); assertThat(logItem.msg).contains(state.getPackageName()); assertThat(logItem.msg).contains(state.getKey()); assertThat(logItem.msg).contains(state.getData()); assertThat(logItem.msg).contains(state.getMessage()); }
Example 2
Source File: AppStatesServiceTest.java From android-testdpc with Apache License 2.0 | 5 votes |
@Test public void onReceive_shouldNotify_noRequestSync_logDoesNotContainRequestSync() { setNotificationPreference(true); mService.onReceive(Arrays.asList(STATE1), /* requestSync= */ false); ShadowLog.LogItem logItem = ShadowLog.getLogsForTag(AppStatesService.TAG).get(0); assertThat(logItem.msg).doesNotContain(REQUEST_SYNC_LOG_TEXT); }
Example 3
Source File: AppStatesServiceTest.java From android-testdpc with Apache License 2.0 | 5 votes |
@Test public void onReceive_shouldNotify_requestSync_logContainsRequestSync() { setNotificationPreference(true); mService.onReceive(Arrays.asList(STATE1), /* requestSync= */ true); ShadowLog.LogItem logItem = ShadowLog.getLogsForTag(AppStatesService.TAG).get(0); assertThat(logItem.msg).contains(REQUEST_SYNC_LOG_TEXT); }
Example 4
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 5
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 6
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 7
Source File: LogLifeCycleProcessorTest.java From loglifecycle with Apache License 2.0 | 5 votes |
@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 8
Source File: LogLifeCycleProcessorTest.java From loglifecycle with Apache License 2.0 | 5 votes |
@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 9
Source File: LogLifeCycleProcessorTest.java From loglifecycle with Apache License 2.0 | 5 votes |
@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 10
Source File: LogLifeCycleProcessorTest.java From loglifecycle with Apache License 2.0 | 5 votes |
@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 11
Source File: LogLifeCycleProcessorTest.java From loglifecycle with Apache License 2.0 | 5 votes |
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"); }
Example 12
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 13
Source File: LegacyUriRedirectHandlerTest.java From rides-android-sdk with MIT License | 4 votes |
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 14
Source File: LegacyUriRedirectHandlerTest.java From rides-android-sdk with MIT License | 4 votes |
private void assertNoLogs() { List<ShadowLog.LogItem> logItemList = ShadowLog.getLogsForTag(UberSdk.UBER_SDK_LOG_TAG); assertThat(ShadowLog.getLogsForTag(UberSdk.UBER_SDK_LOG_TAG)).isNull(); }