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

Unified Diff: chrome/android/javatests/src/org/chromium/chrome/browser/crash/LogcatExtractionCallableTest.java

Issue 1354723004: [android] Change the recommended log tag format to "cr_foo" (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix presubmit test broken by another CL Created 5 years, 3 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
Index: chrome/android/javatests/src/org/chromium/chrome/browser/crash/LogcatExtractionCallableTest.java
diff --git a/chrome/android/javatests/src/org/chromium/chrome/browser/crash/LogcatExtractionCallableTest.java b/chrome/android/javatests/src/org/chromium/chrome/browser/crash/LogcatExtractionCallableTest.java
index 9cf435be42554fd15e2d0417753a44b61bfb85f1..861235f6268c52e64140d15678d50754ead5bf52 100644
--- a/chrome/android/javatests/src/org/chromium/chrome/browser/crash/LogcatExtractionCallableTest.java
+++ b/chrome/android/javatests/src/org/chromium/chrome/browser/crash/LogcatExtractionCallableTest.java
@@ -4,17 +4,10 @@
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 android.content.ComponentName;
import android.content.Context;
import android.content.Intent;
-import android.test.MoreAsserts;
import android.test.suitebuilder.annotation.MediumTest;
-import android.test.suitebuilder.annotation.SmallTest;
-
-import android.text.TextUtils;
import org.chromium.base.test.util.AdvancedMockContext;
@@ -22,11 +15,7 @@
import java.io.File;
import java.io.FileReader;
import java.io.IOException;
-import java.io.StringReader;
-
import java.util.ArrayList;
-import java.util.Arrays;
-import java.util.LinkedList;
import java.util.List;
import java.util.concurrent.atomic.AtomicInteger;
@@ -36,192 +25,11 @@
public class LogcatExtractionCallableTest extends CrashTestCase {
private File mCrashDir;
- private static final int MAX_LINES = 5;
-
protected void setUp() throws Exception {
super.setUp();
mCrashDir = new CrashFileManager(mCacheDir).getCrashDirectory();
}
- @SmallTest
- public void testElideEmail() {
- String original = "email me at someguy@mailservice.com";
- String expected = "email me at XXX@EMAIL.ELIDED";
- assertEquals(expected, LogcatExtractionCallable.elideEmail(original));
- }
-
- @SmallTest
- public void testElideUrl() {
- String original = "file bugs at crbug.com";
- String expected = "file bugs at HTTP://WEBADDRESS.ELIDED";
- assertEquals(expected, LogcatExtractionCallable.elideUrl(original));
- }
-
- @SmallTest
- public void testElideUrl2() {
- String original =
- "exception at org.chromium.chrome.browser.crash.LogcatExtractionCallableTest";
- assertEquals(original, LogcatExtractionCallable.elideUrl(original));
- }
-
- @SmallTest
- public void testElideUrl3() {
- String original = "file bugs at crbug.com or code.google.com";
- String expected = "file bugs at HTTP://WEBADDRESS.ELIDED or HTTP://WEBADDRESS.ELIDED";
- assertEquals(expected, LogcatExtractionCallable.elideUrl(original));
- }
-
- @SmallTest
- public void testElideUrl4() {
- String original = "test shorturl.com !!!";
- String expected = "test HTTP://WEBADDRESS.ELIDED !!!";
- assertEquals(expected, LogcatExtractionCallable.elideUrl(original));
- }
-
- @SmallTest
- public void testElideUrl5() {
- String original = "test just.the.perfect.len.url !!!";
- String expected = "test HTTP://WEBADDRESS.ELIDED !!!";
- assertEquals(expected, LogcatExtractionCallable.elideUrl(original));
- }
-
- @SmallTest
- public void testElideUrl6() {
- String original = "test a.very.very.very.very.very.long.url !!!";
- String expected = "test HTTP://WEBADDRESS.ELIDED !!!";
- assertEquals(expected, LogcatExtractionCallable.elideUrl(original));
- }
-
- @SmallTest
- public void testElideUrl7() {
- String original = " at android.content.Intent \n at java.util.ArrayList";
- assertEquals(original, LogcatExtractionCallable.elideUrl(original));
- }
-
- @SmallTest
- public void testElideIp() {
- String original = "traceroute 127.0.0.1";
- String expected = "traceroute 1.2.3.4";
- assertEquals(expected, LogcatExtractionCallable.elideIp(original));
- }
-
- @SmallTest
- public void testElideMac1() {
- String original = "MAC: AB-AB-AB-AB-AB-AB";
- String expected = "MAC: 01:23:45:67:89:AB";
- assertEquals(expected, LogcatExtractionCallable.elideMac(original));
- }
-
- @SmallTest
- public void testElideMac2() {
- String original = "MAC: AB:AB:AB:AB:AB:AB";
- String expected = "MAC: 01:23:45:67:89:AB";
- assertEquals(expected, LogcatExtractionCallable.elideMac(original));
- }
-
- @SmallTest
- public void testElideConsole() {
- String original = "I/chromium(123): [INFO:CONSOLE(2)] hello!";
- String expected = "I/chromium(123): [ELIDED:CONSOLE(0)] ELIDED CONSOLE MESSAGE";
- assertEquals(expected, LogcatExtractionCallable.elideConsole(original));
- }
-
- @SmallTest
- 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());
- }
- MoreAsserts.assertEquals(expected.toArray(), logcat.toArray());
- }
-
- @SmallTest
- public void testLogcatWithoutBeginOrEnd_smallLogcat() {
- final List<String> original = Arrays.asList("Line 1", "Line 2", "Line 3", "Line 4",
- "Line 5");
- assertLogcatLists(original, original);
- }
-
- @SmallTest
- public void testLogcatWithoutBeginOrEnd_largeLogcat() {
- final List<String> original = Arrays.asList("Line 1", "Line 2", "Line 3", "Line 4",
- "Line 5", "Redundant Line 1", "Redundant Line 2");
- final List<String> expected = Arrays.asList("Line 1", "Line 2", "Line 3", "Line 4",
- "Line 5");
- assertLogcatLists(expected, original);
- }
-
- @SmallTest
- public void testLogcatBeginsWithBegin() {
- final List<String> original = Arrays.asList(BEGIN_MICRODUMP, "a", "b", "c", "d", "e");
- assertLogcatLists(new LinkedList<String>(), original);
- }
-
- @SmallTest
- public void testLogcatWithBegin() {
- final List<String> original = Arrays.asList("Line 1", "Line 2", BEGIN_MICRODUMP, "a",
- "b", "c", "d", "e");
- final List<String> expected = Arrays.asList("Line 1", "Line 2");
- assertLogcatLists(expected, original);
- }
-
- @SmallTest
- public void testLogcatWithEnd() {
- final List<String> original = Arrays.asList("Line 1", "Line 2", END_MICRODUMP);
- assertLogcatLists(new LinkedList<String>(), original);
- }
-
- @SmallTest
- public void testLogcatWithBeginAndEnd_smallLogcat() {
- final List<String> original = Arrays.asList("Line 1", "Line 2", BEGIN_MICRODUMP, "a", "b",
- "c", "d", "e", END_MICRODUMP);
- final List<String> expected = Arrays.asList("Line 1", "Line 2");
- assertLogcatLists(expected, original);
- }
-
- @SmallTest
- public void testLogcatWithBeginAndEnd_largeLogcat() {
- final List<String> original = Arrays.asList("Line 1", "Line 2", BEGIN_MICRODUMP, "a", "b",
- "c", "d", "e", END_MICRODUMP, "Line 3", "Line 4");
- final List<String> expected = Arrays.asList("Line 1", "Line 2", "Line 3", "Line 4");
- assertLogcatLists(expected, original);
- }
-
- @SmallTest
- public void testLogcatWithEndAndBegin_smallLogcat() {
- final List<String> original = Arrays.asList(END_MICRODUMP, "Line 1", "Line 2",
- BEGIN_MICRODUMP, "a", "b", "c", "d", "e");
- final List<String> expected = Arrays.asList("Line 1", "Line 2");
- assertLogcatLists(expected, original);
- }
-
- @SmallTest
- public void testLogcatWithEndAndBegin_largeLogcat() {
- final List<String> original = Arrays.asList(END_MICRODUMP, "Line 1", "Line 2",
- BEGIN_MICRODUMP, "a", "b", "c", "d", "e", END_MICRODUMP, "Line 3", "Line 4");
- final List<String> expected = Arrays.asList("Line 1", "Line 2", "Line 3", "Line 4");
- assertLogcatLists(expected, original);
- }
-
- 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());
- }
- MoreAsserts.assertEquals(expected.toArray(), actualLogcat.toArray());
- }
-
@MediumTest
public void testExtractToFile() {
final AtomicInteger numServiceStarts = new AtomicInteger(0);

Powered by Google App Engine
This is Rietveld 408576698