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

Unified Diff: PRESUBMIT_test.py

Issue 1131903007: [Android log] Promote using hardcoded string tags (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebased, renamed the android group check Created 5 years, 6 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/Log.java » ('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 195fe4f83241340d42e682e6f4c7aea503c7d2b4..613fd41c1cfcf5e505312de2f62da9ca10ad2107 100755
--- a/PRESUBMIT_test.py
+++ b/PRESUBMIT_test.py
@@ -859,6 +859,77 @@ class LogUsageTest(unittest.TestCase):
self.assertTrue('HasAndroidLog.java' in warnings[0].items[0])
self.assertTrue('HasExplicitLog.java' in warnings[0].items[1])
+ def testCheckAndroidCrLogUsage(self):
+ mock_input_api = MockInputApi()
+ mock_output_api = MockOutputApi()
+
+ mock_input_api.files = [
+ MockAffectedFile('RandomStuff.java', [
+ 'random stuff'
+ ]),
+ MockAffectedFile('HasCorrectTag.java', [
+ 'import org.chromium.base.Log;',
+ 'some random stuff',
+ 'private static final String TAG = "cr.Foo";',
+ 'Log.d(TAG, "foo");',
+ ]),
+ MockAffectedFile('HasShortCorrectTag.java', [
+ 'import org.chromium.base.Log;',
+ 'some random stuff',
+ 'private static final String TAG = "cr";',
+ 'Log.d(TAG, "foo");',
+ ]),
+ MockAffectedFile('HasNoTagDecl.java', [
+ 'import org.chromium.base.Log;',
+ 'some random stuff',
+ 'Log.d(TAG, "foo");',
+ ]),
+ MockAffectedFile('HasIncorrectTagDecl.java', [
+ 'import org.chromium.base.Log;',
+ 'private static final String TAHG = "cr.Foo";',
+ 'some random stuff',
+ 'Log.d(TAG, "foo");',
+ ]),
+ MockAffectedFile('HasInlineTag.java', [
+ 'import org.chromium.base.Log;',
+ 'some random stuff',
+ 'private static final String TAG = "cr.Foo";',
+ 'Log.d("TAG", "foo");',
+ ]),
+ MockAffectedFile('HasIncorrectTag.java', [
+ 'import org.chromium.base.Log;',
+ 'some random stuff',
+ 'private static final String TAG = "rubbish";',
+ 'Log.d(TAG, "foo");',
+ ]),
+ MockAffectedFile('HasTooLongTag.java', [
+ 'import org.chromium.base.Log;',
+ 'some random stuff',
+ 'private static final String TAG = "cr.24_charachers_long___";',
+ 'Log.d(TAG, "foo");',
+ ]),
+ ]
+
+ msgs = PRESUBMIT._CheckAndroidCrLogUsage(
+ mock_input_api, mock_output_api)
+
+ self.assertEqual(3, len(msgs))
+
+ # Declaration format
+ self.assertEqual(3, len(msgs[0].items))
+ self.assertTrue('HasNoTagDecl.java' in msgs[0].items)
+ self.assertTrue('HasIncorrectTagDecl.java' in msgs[0].items)
+ self.assertTrue('HasIncorrectTag.java' in msgs[0].items)
+
+ # Tag length
+ self.assertEqual(1, len(msgs[1].items))
+ self.assertTrue('HasTooLongTag.java' in msgs[1].items)
+
+ # Tag must be a variable named TAG
+ self.assertEqual(1, len(msgs[2].items))
+ self.assertTrue('HasInlineTag.java:4' in msgs[2].items)
+
+
if __name__ == '__main__':
unittest.main()
« no previous file with comments | « PRESUBMIT.py ('k') | base/android/java/src/org/chromium/base/Log.java » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698