@Test
public void processNewLineHandlesUserNewlines() {

  // Logcat output for "1: {\n}"
  myReceiver.processNewLine("[ 1516739696.789 99:99 V/UnknownClient     ]");
  myReceiver.processNewLine("1: {");
  myReceiver.processNewLine("}");
  myReceiver.processNewLine("");
  // Logcat output for "2: {\n\n}"
  myReceiver.processNewLine("[ 1516739696.790 99:99 V/UnknownClient     ]");
  myReceiver.processNewLine("2: {");
  myReceiver.processNewLine("");
  myReceiver.processNewLine("}");
  myReceiver.processNewLine("");
  // Logcat output for "3: {\n\n\n}"
  myReceiver.processNewLine("[ 1516739696.791 99:99 V/UnknownClient     ]");
  myReceiver.processNewLine("3: {");
  myReceiver.processNewLine("");
  myReceiver.processNewLine("");
  myReceiver.processNewLine("}");
  myReceiver.processNewLine("");
  // Logcat output for "\n\nleading-trimmed"
  myReceiver.processNewLine("[ 1516739696.792 99:99 V/UnknownClient     ]");
  myReceiver.processNewLine("");
  myReceiver.processNewLine("");
  myReceiver.processNewLine("leading-trimmed");
  myReceiver.processNewLine("");
  // Logcat output for "trailing-trimmed: {\n\n"
  myReceiver.processNewLine("[ 1516739696.793 99:99 V/UnknownClient     ]");
  myReceiver.processNewLine("trailing-trimmed: {");
  myReceiver.processNewLine("");
  myReceiver.processNewLine("");
  myReceiver.processNewLine("");
  // Logcat output for "spaces: { \n \n \n }"
  myReceiver.processNewLine("[ 1516739696.794 99:99 V/UnknownClient     ]");
  myReceiver.processNewLine("spaces: { ");
  myReceiver.processNewLine(" ");
  myReceiver.processNewLine(" ");
  myReceiver.processNewLine(" }");
  myReceiver.processNewLine("");
  // One final entry so any remaining newlines are processed
  myReceiver.processNewLine("[ 1516739696.795 99:99 V/UnknownClient     ]");
  myReceiver.processNewLine("normal log entry");
  String expected = "2018-01-23 12:34:56.789 99-99/? V/UnknownClient: 1: {\n" +
                    "+ }\n" +
                    "2018-01-23 12:34:56.790 99-99/? V/UnknownClient: 2: {\n" +
                    "+ \n" +
                    "+ }\n" +
                    "2018-01-23 12:34:56.791 99-99/? V/UnknownClient: 3: {\n" +
                    "+ \n" +
                    "+ \n" +
                    "+ }\n" +
                    "2018-01-23 12:34:56.792 99-99/? V/UnknownClient: leading-trimmed\n" +
                    "2018-01-23 12:34:56.793 99-99/? V/UnknownClient: trailing-trimmed: {\n" +
                    "2018-01-23 12:34:56.794 99-99/? V/UnknownClient: spaces: { \n" +
                    "+  \n" +
                    "+  \n" +
                    "+  }\n" +
                    "2018-01-23 12:34:56.795 99-99/? V/UnknownClient: normal log entry\n";
  assertThat(myLogcatListener.toString()).isEqualTo(expected);
}