| 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 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 371 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 382 MockFile('other/path/qux.h', ''), | 382 MockFile('other/path/qux.h', ''), |
| 383 MockFile('other/path/qux.cc', ''), | 383 MockFile('other/path/qux.cc', ''), |
| 384 ] | 384 ] |
| 385 results = PRESUBMIT._CheckPatchFiles(mock_input_api, MockOutputApi()) | 385 results = PRESUBMIT._CheckPatchFiles(mock_input_api, MockOutputApi()) |
| 386 self.assertEqual(0, len(results)) | 386 self.assertEqual(0, len(results)) |
| 387 | 387 |
| 388 | 388 |
| 389 class CheckSingletonInHeadersTest(unittest.TestCase): | 389 class CheckSingletonInHeadersTest(unittest.TestCase): |
| 390 def testSingletonInArbitraryHeader(self): | 390 def testSingletonInArbitraryHeader(self): |
| 391 diff_singleton_h = ['base::subtle::AtomicWord ' | 391 diff_singleton_h = ['base::subtle::AtomicWord ' |
| 392 'Singleton<Type, Traits, DifferentiatingType>::'] | 392 'base::Singleton<Type, Traits, DifferentiatingType>::'] |
| 393 diff_foo_h = ['// Singleton<Foo> in comment.', | 393 diff_foo_h = ['// base::Singleton<Foo> in comment.', |
| 394 'friend class Singleton<Foo>'] | 394 'friend class base::Singleton<Foo>'] |
| 395 diff_bad_h = ['Foo* foo = Singleton<Foo>::get();'] | 395 diff_bad_h = ['Foo* foo = base::Singleton<Foo>::get();'] |
| 396 mock_input_api = MockInputApi() | 396 mock_input_api = MockInputApi() |
| 397 mock_input_api.files = [MockAffectedFile('base/memory/singleton.h', | 397 mock_input_api.files = [MockAffectedFile('base/memory/singleton.h', |
| 398 diff_singleton_h), | 398 diff_singleton_h), |
| 399 MockAffectedFile('foo.h', diff_foo_h), | 399 MockAffectedFile('foo.h', diff_foo_h), |
| 400 MockAffectedFile('bad.h', diff_bad_h)] | 400 MockAffectedFile('bad.h', diff_bad_h)] |
| 401 warnings = PRESUBMIT._CheckSingletonInHeaders(mock_input_api, | 401 warnings = PRESUBMIT._CheckSingletonInHeaders(mock_input_api, |
| 402 MockOutputApi()) | 402 MockOutputApi()) |
| 403 self.assertEqual(1, len(warnings)) | 403 self.assertEqual(1, len(warnings)) |
| 404 self.assertEqual('error', warnings[0].type) | 404 self.assertEqual('error', warnings[0].type) |
| 405 self.assertTrue('Found Singleton<T>' in warnings[0].message) | 405 self.assertTrue('Found base::Singleton<T>' in warnings[0].message) |
| 406 | 406 |
| 407 def testSingletonInCC(self): | 407 def testSingletonInCC(self): |
| 408 diff_cc = ['Foo* foo = Singleton<Foo>::get();'] | 408 diff_cc = ['Foo* foo = base::Singleton<Foo>::get();'] |
| 409 mock_input_api = MockInputApi() | 409 mock_input_api = MockInputApi() |
| 410 mock_input_api.files = [MockAffectedFile('some/path/foo.cc', diff_cc)] | 410 mock_input_api.files = [MockAffectedFile('some/path/foo.cc', diff_cc)] |
| 411 warnings = PRESUBMIT._CheckSingletonInHeaders(mock_input_api, | 411 warnings = PRESUBMIT._CheckSingletonInHeaders(mock_input_api, |
| 412 MockOutputApi()) | 412 MockOutputApi()) |
| 413 self.assertEqual(0, len(warnings)) | 413 self.assertEqual(0, len(warnings)) |
| 414 | 414 |
| 415 | 415 |
| 416 class InvalidOSMacroNamesTest(unittest.TestCase): | 416 class InvalidOSMacroNamesTest(unittest.TestCase): |
| 417 def testInvalidOSMacroNames(self): | 417 def testInvalidOSMacroNames(self): |
| 418 lines = ['#if defined(OS_WINDOWS)', | 418 lines = ['#if defined(OS_WINDOWS)', |
| (...skipping 500 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 919 self.assertTrue('HasInlineTag.java:4' in msgs[2].items) | 919 self.assertTrue('HasInlineTag.java:4' in msgs[2].items) |
| 920 | 920 |
| 921 # Util Log usage | 921 # Util Log usage |
| 922 self.assertEqual(2, len(msgs[3].items)) | 922 self.assertEqual(2, len(msgs[3].items)) |
| 923 self.assertTrue('HasAndroidLog.java:3' in msgs[3].items) | 923 self.assertTrue('HasAndroidLog.java:3' in msgs[3].items) |
| 924 self.assertTrue('IsInBasePackageButImportsLog.java:4' in msgs[3].items) | 924 self.assertTrue('IsInBasePackageButImportsLog.java:4' in msgs[3].items) |
| 925 | 925 |
| 926 | 926 |
| 927 if __name__ == '__main__': | 927 if __name__ == '__main__': |
| 928 unittest.main() | 928 unittest.main() |
| OLD | NEW |