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

Unified Diff: content/public/android/junit/src/org/chromium/base/LogTest.java

Issue 1048153002: Add an utility class to improve java logs. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Add overrides of the log functions to allow proguard to properly remove arguments Created 5 years, 9 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: content/public/android/junit/src/org/chromium/base/LogTest.java
diff --git a/content/public/android/junit/src/org/chromium/base/LogTest.java b/content/public/android/junit/src/org/chromium/base/LogTest.java
new file mode 100644
index 0000000000000000000000000000000000000000..89da608aa0710b4c8d21b291826201bba253d751
--- /dev/null
+++ b/content/public/android/junit/src/org/chromium/base/LogTest.java
@@ -0,0 +1,31 @@
+// Copyright 2015 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+package org.chromium.base;
Yaron 2015/04/01 20:47:31 This should be in a base/ folder if it's package b
dgn 2015/04/02 12:47:20 It's a unit test, no apk required to run it. I can
Yaron 2015/04/02 14:29:47 Ok, sounds good
+
+import static org.junit.Assert.assertFalse;
+
+import org.chromium.testing.local.LocalRobolectricTestRunner;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.robolectric.annotation.Config;
+
+@RunWith(LocalRobolectricTestRunner.class)
+@Config(manifest = Config.NONE)
+public class LogTest {
+ @Test(expected = IllegalArgumentException.class)
+ public void tooLongTagExceptionTest() {
+ new Log("OneCharTooLong!");
+ }
+
+ @Test
+ public void allowedTagsNoExceptionTest() {
+ // See android.util.Log#isLoggable(String, int)}'s doc.
+ final int maxAllowedTagLength = 23;
+ assertFalse(new Log(null).mTag.length() > maxAllowedTagLength);
+ assertFalse(new Log("").mTag.length() > maxAllowedTagLength);
+ assertFalse(new Log("Foo").mTag.length() > maxAllowedTagLength);
+ assertFalse(new Log("LongestAllowed").mTag.length() > maxAllowedTagLength);
+ }
+}

Powered by Google App Engine
This is Rietveld 408576698