| OLD | NEW |
| 1 #!/usr/bin/env python | 1 #!/usr/bin/env python |
| 2 # Copyright 2015 The Chromium Authors. All rights reserved. | 2 # Copyright 2015 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 # pylint: disable=protected-access | 6 # pylint: disable=protected-access |
| 7 | 7 |
| 8 import itertools | 8 import itertools |
| 9 import os |
| 9 import sys | 10 import sys |
| 10 import unittest | 11 import unittest |
| 11 | 12 |
| 12 from devil import devil_env | |
| 13 from devil.android import logcat_monitor | 13 from devil.android import logcat_monitor |
| 14 from devil.android.sdk import adb_wrapper | 14 from devil.android.sdk import adb_wrapper |
| 15 from pylib import constants |
| 15 | 16 |
| 16 sys.path.append(devil_env.config.LocalPath('pymock')) | 17 sys.path.append(os.path.join( |
| 17 import mock # pylint: disable=import-error | 18 constants.DIR_SOURCE_ROOT, 'third_party', 'pymock')) |
| 19 import mock # pylint: disable=F0401 |
| 18 | 20 |
| 19 | 21 |
| 20 def _CreateTestLog(raw_logcat=None): | 22 def _CreateTestLog(raw_logcat=None): |
| 21 test_adb = adb_wrapper.AdbWrapper('0123456789abcdef') | 23 test_adb = adb_wrapper.AdbWrapper('0123456789abcdef') |
| 22 test_adb.Logcat = mock.Mock(return_value=(l for l in raw_logcat)) | 24 test_adb.Logcat = mock.Mock(return_value=(l for l in raw_logcat)) |
| 23 test_log = logcat_monitor.LogcatMonitor(test_adb, clear=False) | 25 test_log = logcat_monitor.LogcatMonitor(test_adb, clear=False) |
| 24 return test_log | 26 return test_log |
| 25 | 27 |
| 26 | 28 |
| 27 class LogcatMonitorTest(unittest.TestCase): | 29 class LogcatMonitorTest(unittest.TestCase): |
| (...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 155 ('2345', '5432', 'F', 'LogcatMonitorTest', | 157 ('2345', '5432', 'F', 'LogcatMonitorTest', |
| 156 'fatal logcat monitor test message 6'), | 158 'fatal logcat monitor test message 6'), |
| 157 ('3456', '6543', 'D', 'LogcatMonitorTest', | 159 ('3456', '6543', 'D', 'LogcatMonitorTest', |
| 158 'ignore me'),] | 160 'ignore me'),] |
| 159 self.assertIterEqual(iter(expected_results), actual_results) | 161 self.assertIterEqual(iter(expected_results), actual_results) |
| 160 | 162 |
| 161 | 163 |
| 162 if __name__ == '__main__': | 164 if __name__ == '__main__': |
| 163 unittest.main(verbosity=2) | 165 unittest.main(verbosity=2) |
| 164 | 166 |
| OLD | NEW |