OLD | NEW |
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 re | 6 import re |
7 import subprocess | 7 import subprocess |
8 import unittest | 8 import unittest |
9 | 9 |
10 import PRESUBMIT | 10 import PRESUBMIT |
(...skipping 1113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1124 self.assertTrue('HasAndroidLog.java:3' in msgs[3].items) | 1124 self.assertTrue('HasAndroidLog.java:3' in msgs[3].items) |
1125 self.assertTrue('IsInBasePackageButImportsLog.java:4' in msgs[3].items) | 1125 self.assertTrue('IsInBasePackageButImportsLog.java:4' in msgs[3].items) |
1126 | 1126 |
1127 # Tag must not contain | 1127 # Tag must not contain |
1128 nb = len(msgs[4].items) | 1128 nb = len(msgs[4].items) |
1129 self.assertEqual(2, nb, | 1129 self.assertEqual(2, nb, |
1130 'Expected %d items, found %d: %s' % (2, nb, msgs[4].items)) | 1130 'Expected %d items, found %d: %s' % (2, nb, msgs[4].items)) |
1131 self.assertTrue('HasDottedTag.java' in msgs[4].items) | 1131 self.assertTrue('HasDottedTag.java' in msgs[4].items) |
1132 self.assertTrue('HasOldTag.java' in msgs[4].items) | 1132 self.assertTrue('HasOldTag.java' in msgs[4].items) |
1133 | 1133 |
| 1134 class GoogleAnswerUrlFormatTest(unittest.TestCase): |
| 1135 |
| 1136 def testCatchAnswerUrlId(self): |
| 1137 input_api = MockInputApi() |
| 1138 input_api.files = [ |
| 1139 MockFile('somewhere/file.cc', |
| 1140 ['char* host = ' |
| 1141 ' "https://support.google.com/chrome/answer/123456";']), |
| 1142 MockFile('somewhere_else/file.cc', |
| 1143 ['char* host = ' |
| 1144 ' "https://support.google.com/chrome/a/answer/123456";']), |
| 1145 ] |
| 1146 |
| 1147 warnings = PRESUBMIT._CheckGoogleSupportAnswerUrl( |
| 1148 input_api, MockOutputApi()) |
| 1149 self.assertEqual(1, len(warnings)) |
| 1150 self.assertEqual(2, len(warnings[0].items)) |
| 1151 |
| 1152 def testAllowAnswerUrlParam(self): |
| 1153 input_api = MockInputApi() |
| 1154 input_api.files = [ |
| 1155 MockFile('somewhere/file.cc', |
| 1156 ['char* host = ' |
| 1157 ' "https://support.google.com/chrome/?p=cpn_crash_reports";']), |
| 1158 ] |
| 1159 |
| 1160 warnings = PRESUBMIT._CheckGoogleSupportAnswerUrl( |
| 1161 input_api, MockOutputApi()) |
| 1162 self.assertEqual(0, len(warnings)) |
| 1163 |
1134 class HardcodedGoogleHostsTest(unittest.TestCase): | 1164 class HardcodedGoogleHostsTest(unittest.TestCase): |
1135 | 1165 |
1136 def testWarnOnAssignedLiterals(self): | 1166 def testWarnOnAssignedLiterals(self): |
1137 input_api = MockInputApi() | 1167 input_api = MockInputApi() |
1138 input_api.files = [ | 1168 input_api.files = [ |
1139 MockFile('content/file.cc', | 1169 MockFile('content/file.cc', |
1140 ['char* host = "https://www.google.com";']), | 1170 ['char* host = "https://www.google.com";']), |
1141 MockFile('content/file.cc', | 1171 MockFile('content/file.cc', |
1142 ['char* host = "https://www.googleapis.com";']), | 1172 ['char* host = "https://www.googleapis.com";']), |
1143 MockFile('content/file.cc', | 1173 MockFile('content/file.cc', |
(...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1266 mock_input_api.files = [ | 1296 mock_input_api.files = [ |
1267 MockAffectedFile('chrome/browser/resources/blah.js', 'arrow => OK here'), | 1297 MockAffectedFile('chrome/browser/resources/blah.js', 'arrow => OK here'), |
1268 ] | 1298 ] |
1269 warnings = PRESUBMIT._CheckForRiskyJsFeatures( | 1299 warnings = PRESUBMIT._CheckForRiskyJsFeatures( |
1270 mock_input_api, MockOutputApi()) | 1300 mock_input_api, MockOutputApi()) |
1271 self.assertEqual(0, len(warnings)) | 1301 self.assertEqual(0, len(warnings)) |
1272 | 1302 |
1273 | 1303 |
1274 if __name__ == '__main__': | 1304 if __name__ == '__main__': |
1275 unittest.main() | 1305 unittest.main() |
OLD | NEW |