Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(4648)

Unified Diff: chrome/android/junit/src/org/chromium/chrome/browser/crash/LogcatExtractionCallableUnitTest.java

Issue 2418923002: [Merge] [Android] Fix logcat extraction code. (Closed)
Patch Set: Created 4 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/android/java/src/org/chromium/chrome/browser/crash/LogcatExtractionCallable.java ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/android/junit/src/org/chromium/chrome/browser/crash/LogcatExtractionCallableUnitTest.java
diff --git a/chrome/android/junit/src/org/chromium/chrome/browser/crash/LogcatExtractionCallableUnitTest.java b/chrome/android/junit/src/org/chromium/chrome/browser/crash/LogcatExtractionCallableUnitTest.java
index 73198af26dbb49556a757a07e9c4ceb45b80e50b..226330879b68d6f39c140e73fa8a2bdc29e767f6 100644
--- a/chrome/android/junit/src/org/chromium/chrome/browser/crash/LogcatExtractionCallableUnitTest.java
+++ b/chrome/android/junit/src/org/chromium/chrome/browser/crash/LogcatExtractionCallableUnitTest.java
@@ -4,22 +4,19 @@
package org.chromium.chrome.browser.crash;
-import static org.chromium.chrome.browser.crash.LogcatExtractionCallable.BEGIN_MICRODUMP;
-import static org.chromium.chrome.browser.crash.LogcatExtractionCallable.END_MICRODUMP;
-import static org.chromium.chrome.browser.crash.LogcatExtractionCallable.SNIPPED_MICRODUMP;
import static org.junit.Assert.assertArrayEquals;
import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.fail;
-import android.text.TextUtils;
+import static org.chromium.chrome.browser.crash.LogcatExtractionCallable.BEGIN_MICRODUMP;
+import static org.chromium.chrome.browser.crash.LogcatExtractionCallable.END_MICRODUMP;
+import static org.chromium.chrome.browser.crash.LogcatExtractionCallable.SNIPPED_MICRODUMP;
-import org.chromium.testing.local.LocalRobolectricTestRunner;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.robolectric.annotation.Config;
-import java.io.BufferedReader;
-import java.io.StringReader;
+import org.chromium.testing.local.LocalRobolectricTestRunner;
+
import java.util.Arrays;
import java.util.LinkedList;
import java.util.List;
@@ -129,16 +126,8 @@ public class LogcatExtractionCallableUnitTest {
@Test
public void testLogcatEmpty() {
- final String original = "";
- List<String> expected = new LinkedList<>();
- List<String> logcat = null;
- try {
- logcat = LogcatExtractionCallable.extractLogcatFromReader(
- new BufferedReader(new StringReader(original)), MAX_LINES);
- } catch (Exception e) {
- fail(e.toString());
- }
- assertArrayEquals(expected.toArray(), logcat.toArray());
+ final List<String> original = new LinkedList<>();
+ assertLogcatLists(original, original);
}
@Test
@@ -224,16 +213,9 @@ public class LogcatExtractionCallableUnitTest {
}
private void assertLogcatLists(List<String> expected, List<String> original) {
- List<String> actualLogcat = null;
- String combinedLogcat = TextUtils.join("\n", original);
- try {
- //simulate a file reader to test whether the extraction process
- //successfully strips microdump from logcat
- actualLogcat = LogcatExtractionCallable.extractLogcatFromReader(
- new BufferedReader(new StringReader(combinedLogcat)), MAX_LINES);
- } catch (Exception e) {
- fail(e.toString());
- }
+ // trimLogcat() expects a modifiable list as input.
+ LinkedList<String> rawLogcat = new LinkedList<String>(original);
+ List<String> actualLogcat = LogcatExtractionCallable.trimLogcat(rawLogcat, MAX_LINES);
assertArrayEquals(expected.toArray(), actualLogcat.toArray());
}
}
« no previous file with comments | « chrome/android/java/src/org/chromium/chrome/browser/crash/LogcatExtractionCallable.java ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698