| 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 394 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 405 | 405 |
| 406 def testSingletonInCC(self): | 406 def testSingletonInCC(self): |
| 407 diff_cc = ['Foo* foo = base::Singleton<Foo>::get();'] | 407 diff_cc = ['Foo* foo = base::Singleton<Foo>::get();'] |
| 408 mock_input_api = MockInputApi() | 408 mock_input_api = MockInputApi() |
| 409 mock_input_api.files = [MockAffectedFile('some/path/foo.cc', diff_cc)] | 409 mock_input_api.files = [MockAffectedFile('some/path/foo.cc', diff_cc)] |
| 410 warnings = PRESUBMIT._CheckSingletonInHeaders(mock_input_api, | 410 warnings = PRESUBMIT._CheckSingletonInHeaders(mock_input_api, |
| 411 MockOutputApi()) | 411 MockOutputApi()) |
| 412 self.assertEqual(0, len(warnings)) | 412 self.assertEqual(0, len(warnings)) |
| 413 | 413 |
| 414 | 414 |
| 415 class CheckNoDeprecatedCompiledResourcesGYPTest(unittest.TestCase): | 415 class CheckNoDeprecatedCompiledResourcesGypTest(unittest.TestCase): |
| 416 def testNoDeprecatedCompiledResourcsGYP(self): | 416 def testNoDeprecatedCompiledResourcsGyp(self): |
| 417 mock_input_api = MockInputApi() | 417 mock_input_api = MockInputApi() |
| 418 mock_input_api.files = [MockFile('some/js/compiled_resources.gyp', [])] | 418 mock_input_api.files = [MockFile('some/js/compiled_resources.gyp', [])] |
| 419 errors = PRESUBMIT._CheckNoDeprecatedCompiledResourcesGYP(mock_input_api, | 419 errors = PRESUBMIT._CheckNoDeprecatedCompiledResourcesGyp(mock_input_api, |
| 420 MockOutputApi()) | 420 MockOutputApi()) |
| 421 self.assertEquals(1, len(errors)) | 421 self.assertEquals(1, len(errors)) |
| 422 | 422 |
| 423 mock_input_api.files = [MockFile('some/js/compiled_resources2.gyp', [])] | 423 mock_input_api.files = [MockFile('some/js/compiled_resources2.gyp', [])] |
| 424 errors = PRESUBMIT._CheckNoDeprecatedCompiledResourcesGYP(mock_input_api, | 424 errors = PRESUBMIT._CheckNoDeprecatedCompiledResourcesGyp(mock_input_api, |
| 425 MockOutputApi()) | 425 MockOutputApi()) |
| 426 self.assertEquals(0, len(errors)) | 426 self.assertEquals(0, len(errors)) |
| 427 | 427 |
| 428 | 428 |
| 429 class InvalidOSMacroNamesTest(unittest.TestCase): | 429 class InvalidOSMacroNamesTest(unittest.TestCase): |
| 430 def testInvalidOSMacroNames(self): | 430 def testInvalidOSMacroNames(self): |
| 431 lines = ['#if defined(OS_WINDOWS)', | 431 lines = ['#if defined(OS_WINDOWS)', |
| 432 ' #elif defined(OS_WINDOW)', | 432 ' #elif defined(OS_WINDOW)', |
| 433 ' # if defined(OS_MACOSX) || defined(OS_CHROME)', | 433 ' # if defined(OS_MACOSX) || defined(OS_CHROME)', |
| 434 '# else // defined(OS_MAC)', | 434 '# else // defined(OS_MAC)', |
| (...skipping 746 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1181 MockAffectedFile('third_party\\WebKit\\header.h', [ | 1181 MockAffectedFile('third_party\\WebKit\\header.h', [ |
| 1182 'class DummyClass;', | 1182 'class DummyClass;', |
| 1183 'struct DummyStruct;', | 1183 'struct DummyStruct;', |
| 1184 ]) | 1184 ]) |
| 1185 ] | 1185 ] |
| 1186 warnings = PRESUBMIT._CheckUselessForwardDeclarations(mock_input_api, | 1186 warnings = PRESUBMIT._CheckUselessForwardDeclarations(mock_input_api, |
| 1187 MockOutputApi()) | 1187 MockOutputApi()) |
| 1188 self.assertEqual(4, len(warnings)) | 1188 self.assertEqual(4, len(warnings)) |
| 1189 | 1189 |
| 1190 | 1190 |
| 1191 class RiskyJsTest(unittest.TestCase): |
| 1192 def testArrowWarnInIos9Code(self): |
| 1193 mock_input_api = MockInputApi() |
| 1194 mock_output_api = MockOutputApi() |
| 1195 |
| 1196 mock_input_api.files = [ |
| 1197 MockAffectedFile('components/blah.js', ["shouldn't use => here"]), |
| 1198 ] |
| 1199 warnings = PRESUBMIT._CheckForRiskyJsFeatures( |
| 1200 mock_input_api, mock_output_api) |
| 1201 self.assertEqual(1, len(warnings)) |
| 1202 |
| 1203 mock_input_api.files = [ |
| 1204 MockAffectedFile('ios/blee.js', ['might => break folks']), |
| 1205 ] |
| 1206 warnings = PRESUBMIT._CheckForRiskyJsFeatures( |
| 1207 mock_input_api, mock_output_api) |
| 1208 self.assertEqual(1, len(warnings)) |
| 1209 |
| 1210 mock_input_api.files = [ |
| 1211 MockAffectedFile('ui/webui/resources/blarg.js', ['on => iOS9']), |
| 1212 ] |
| 1213 warnings = PRESUBMIT._CheckForRiskyJsFeatures( |
| 1214 mock_input_api, mock_output_api) |
| 1215 self.assertEqual(1, len(warnings)) |
| 1216 |
| 1217 def testArrowsAllowedInChromeCode(self): |
| 1218 mock_input_api = MockInputApi() |
| 1219 mock_input_api.files = [ |
| 1220 MockAffectedFile('chrome/browser/resources/blah.js', 'arrow => OK here'), |
| 1221 ] |
| 1222 warnings = PRESUBMIT._CheckForRiskyJsFeatures( |
| 1223 mock_input_api, MockOutputApi()) |
| 1224 self.assertEqual(0, len(warnings)) |
| 1225 |
| 1226 |
| 1191 if __name__ == '__main__': | 1227 if __name__ == '__main__': |
| 1192 unittest.main() | 1228 unittest.main() |
| OLD | NEW |