Hajime Hoshi | 1230a8a | 2018-04-11 04:42:30 | [diff] [blame] | 1 | #!/usr/bin/env python |
| 2 | # Copyright 2018 The Chromium Authors. All rights reserved. |
| 3 | # Use of this source code is governed by a BSD-style license that can be |
| 4 | # found in the LICENSE file. |
| 5 | |
| 6 | import os |
| 7 | import sys |
| 8 | import unittest |
| 9 | |
| 10 | import PRESUBMIT |
| 11 | |
| 12 | sys.path.append( |
| 13 | os.path.join(os.path.dirname(os.path.abspath(__file__)), '..', '..')) |
| 14 | from PRESUBMIT_test_mocks import (MockInputApi, MockOutputApi, MockAffectedFile) |
| 15 | |
| 16 | class GetTest(unittest.TestCase): |
| 17 | def testNewUsageThreadTaskRunnerHandleGet(self): |
| 18 | diff = ['scoped_refptr<SingleThreadTaskRunner> task_runner =', |
| 19 | ' base::ThreadTaskRunnerHandle::Get()'] |
| 20 | input_api = MockInputApi() |
| 21 | input_api.files = [MockAffectedFile('content/renderer/foo.cc', diff)] |
| 22 | errors = PRESUBMIT._CheckForUseOfGlobalTaskRunnerGetter(input_api, |
| 23 | MockOutputApi()) |
| 24 | self.assertEqual(1, len(errors)) |
| 25 | |
| 26 | def testNewUsageSequencedTaskRunnerHandleGet(self): |
| 27 | diff = ['scoped_refptr<SequencedThreadTaskRunner> task_runner =', |
| 28 | ' base::SequencedTaskRunnerHandle::Get()'] |
| 29 | input_api = MockInputApi() |
| 30 | input_api.files = [MockAffectedFile('content/renderer/foo.cc', diff)] |
| 31 | errors = PRESUBMIT._CheckForUseOfGlobalTaskRunnerGetter(input_api, |
| 32 | MockOutputApi()) |
| 33 | self.assertEqual(1, len(errors)) |
| 34 | |
| 35 | if __name__ == '__main__': |
| 36 | unittest.main() |