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

Side by Side 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 unified diff | 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 »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 #!/usr/bin/env python 1 #!/usr/bin/env python
2 # Copyright (c) 2012 The Chromium Authors. All rights reserved. 2 # Copyright (c) 2012 The Chromium Authors. All rights reserved.
3 # Use of this source code is governed by a BSD-style license that can be 3 # Use of this source code is governed by a BSD-style license that can be
4 # found in the LICENSE file. 4 # found in the LICENSE file.
5 5
6 import glob 6 import glob
7 import json 7 import json
8 import os 8 import os
9 import re 9 import re
10 import subprocess 10 import subprocess
(...skipping 841 matching lines...) Expand 10 before | Expand all | Expand 10 after
852 ] 852 ]
853 853
854 warnings = PRESUBMIT._CheckNoNewUtilLogUsage( 854 warnings = PRESUBMIT._CheckNoNewUtilLogUsage(
855 mock_input_api, mock_output_api) 855 mock_input_api, mock_output_api)
856 856
857 self.assertEqual(1, len(warnings)) 857 self.assertEqual(1, len(warnings))
858 self.assertEqual(2, len(warnings[0].items)) 858 self.assertEqual(2, len(warnings[0].items))
859 self.assertTrue('HasAndroidLog.java' in warnings[0].items[0]) 859 self.assertTrue('HasAndroidLog.java' in warnings[0].items[0])
860 self.assertTrue('HasExplicitLog.java' in warnings[0].items[1]) 860 self.assertTrue('HasExplicitLog.java' in warnings[0].items[1])
861 861
862 def testCheckAndroidCrLogUsage(self):
863 mock_input_api = MockInputApi()
864 mock_output_api = MockOutputApi()
865
866 mock_input_api.files = [
867 MockAffectedFile('RandomStuff.java', [
868 'random stuff'
869 ]),
870 MockAffectedFile('HasCorrectTag.java', [
871 'import org.chromium.base.Log;',
872 'some random stuff',
873 'private static final String TAG = "cr.Foo";',
874 'Log.d(TAG, "foo");',
875 ]),
876 MockAffectedFile('HasShortCorrectTag.java', [
877 'import org.chromium.base.Log;',
878 'some random stuff',
879 'private static final String TAG = "cr";',
880 'Log.d(TAG, "foo");',
881 ]),
882 MockAffectedFile('HasNoTagDecl.java', [
883 'import org.chromium.base.Log;',
884 'some random stuff',
885 'Log.d(TAG, "foo");',
886 ]),
887 MockAffectedFile('HasIncorrectTagDecl.java', [
888 'import org.chromium.base.Log;',
889 'private static final String TAHG = "cr.Foo";',
890 'some random stuff',
891 'Log.d(TAG, "foo");',
892 ]),
893 MockAffectedFile('HasInlineTag.java', [
894 'import org.chromium.base.Log;',
895 'some random stuff',
896 'private static final String TAG = "cr.Foo";',
897 'Log.d("TAG", "foo");',
898 ]),
899 MockAffectedFile('HasIncorrectTag.java', [
900 'import org.chromium.base.Log;',
901 'some random stuff',
902 'private static final String TAG = "rubbish";',
903 'Log.d(TAG, "foo");',
904 ]),
905 MockAffectedFile('HasTooLongTag.java', [
906 'import org.chromium.base.Log;',
907 'some random stuff',
908 'private static final String TAG = "cr.24_charachers_long___";',
909 'Log.d(TAG, "foo");',
910 ]),
911 ]
912
913 msgs = PRESUBMIT._CheckAndroidCrLogUsage(
914 mock_input_api, mock_output_api)
915
916 self.assertEqual(3, len(msgs))
917
918 # Declaration format
919 self.assertEqual(3, len(msgs[0].items))
920 self.assertTrue('HasNoTagDecl.java' in msgs[0].items)
921 self.assertTrue('HasIncorrectTagDecl.java' in msgs[0].items)
922 self.assertTrue('HasIncorrectTag.java' in msgs[0].items)
923
924 # Tag length
925 self.assertEqual(1, len(msgs[1].items))
926 self.assertTrue('HasTooLongTag.java' in msgs[1].items)
927
928 # Tag must be a variable named TAG
929 self.assertEqual(1, len(msgs[2].items))
930 self.assertTrue('HasInlineTag.java:4' in msgs[2].items)
931
932
862 933
863 if __name__ == '__main__': 934 if __name__ == '__main__':
864 unittest.main() 935 unittest.main()
OLDNEW
« 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