FormattedLogcatReceiver implements AndroidLogcatService.LogcatListener { @Override public final void onLogLineReceived(@NotNull LogCatMessage line) { LogCatHeader header = line.getHeader(); if (myActiveHeader != header) { myActiveHeader = header; receiveFormattedLogLine(myFormatter.formatMessageFull(header, line.getMessage())); } else { String message = AndroidLogcatFormatter.formatContinuation(line.getMessage()); receiveFormattedLogLine(message); } } FormattedLogcatReceiver(@NotNull AndroidLogcatFormatter formatter); @Override final void onLogLineReceived(@NotNull LogCatMessage line);  }
@Test public void onLogLineReceived() { LogcatListener listener = new TestFormattedLogcatReceiver(); Instant timestamp = Instant.parse("2018-04-17T20:33:25.907Z"); LogCatHeader header1 = new LogCatHeader(LogLevel.INFO, 28740, 28740, "com.google.myapplication", "MainActivity", timestamp); listener.onLogLineReceived(new LogCatMessage(header1, "Log 1")); LogCatHeader header2 = new LogCatHeader(LogLevel.INFO, 28740, 28740, "com.google.myapplication", "MainActivity", timestamp); listener.onLogLineReceived(new LogCatMessage(header2, "Log 2")); Object expected = "2018-04-17 13:33:25.907 28740-28740/com.google.myapplication I/MainActivity: Log 1\n" + "2018-04-17 13:33:25.907 28740-28740/com.google.myapplication I/MainActivity: Log 2\n"; assertEquals(expected, listener.toString()); }