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

Unified Diff: PRESUBMIT_test.py

Issue 1114593002: [android log] Add documentation and presubmit checks for log usage. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 8 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 | « PRESUBMIT.py ('k') | base/android/java/src/org/chromium/base/README_logging.md » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: PRESUBMIT_test.py
diff --git a/PRESUBMIT_test.py b/PRESUBMIT_test.py
index 8b642c4efb5039f3c7972a40c5b9dbe680249d56..18e3c6e74d4bd29aceaed5c411749f6bddd99248 100755
--- a/PRESUBMIT_test.py
+++ b/PRESUBMIT_test.py
@@ -809,5 +809,46 @@ class UserMetricsActionTest(unittest.TestCase):
output[0].message)
+class LogUsageTest(unittest.TestCase):
+
+ def testCheckNoNewUtilLogUsage(self):
+ mock_input_api = MockInputApi()
+ mock_output_api = MockOutputApi()
+
+ mock_input_api.files = [
+ MockAffectedFile('RandomStuff.java', [
+ 'random stuff'
+ ]),
+ MockAffectedFile('HasCrLog.java', [
+ 'import org.chromium.base.Log;',
+ 'some random stuff',
+ 'Log.d("TAG", "foo");',
+ ]),
+ MockAffectedFile('HasAndroidLog.java', [
+ 'import android.util.Log;',
+ 'some random stuff',
+ 'Log.d("TAG", "foo");',
+ ]),
+ MockAffectedFile('HasExplicitLog.java', [
+ 'some random stuff',
+ 'android.util.Log.d("TAG", "foo");',
+ ]),
+ MockAffectedFile('HasBothLog.java', [
+ 'import org.chromium.base.Log;',
+ 'some random stuff',
+ 'Log.d("TAG", "foo");',
+ 'android.util.Log.d("TAG", "foo");',
+ ]),
+ ]
+
+ warnings = PRESUBMIT._CheckNoNewUtilLogUsage(
+ mock_input_api, mock_output_api)
+
+ self.assertEqual(1, len(warnings))
+ self.assertEqual(2, len(warnings[0].items))
+ self.assertTrue('HasAndroidLog.java' in warnings[0].items[0])
+ self.assertTrue('HasExplicitLog.java' in warnings[0].items[1])
+
+
if __name__ == '__main__':
unittest.main()
« no previous file with comments | « PRESUBMIT.py ('k') | base/android/java/src/org/chromium/base/README_logging.md » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698