Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(30)

Unified Diff: build/android/devil/android/logcat_monitor_test.py

Issue 1484253003: [Android] Add record functionality to logcat monitor. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Pass device serials to LogcatMonitorCommandErrors. Created 5 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « build/android/devil/android/logcat_monitor.py ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: build/android/devil/android/logcat_monitor_test.py
diff --git a/build/android/devil/android/logcat_monitor_test.py b/build/android/devil/android/logcat_monitor_test.py
index 61985607b399f45cea450c392f8b7596c167ab3f..19dbd75c87ac02171b53f5dadfe67c66337f8cfb 100755
--- a/build/android/devil/android/logcat_monitor_test.py
+++ b/build/android/devil/android/logcat_monitor_test.py
@@ -22,7 +22,6 @@ def _CreateTestLog(raw_logcat=None):
test_log = logcat_monitor.LogcatMonitor(test_adb, clear=False)
return test_log
-
class LogcatMonitorTest(unittest.TestCase):
_TEST_THREADTIME_LOGCAT_DATA = [
@@ -39,7 +38,7 @@ class LogcatMonitorTest(unittest.TestCase):
'01-01 01:02:03.461 2345 5432 F LogcatMonitorTest: '
'fatal logcat monitor test message 6',
'01-01 01:02:03.462 3456 6543 D LogcatMonitorTest: '
- 'ignore me',]
+ 'last line',]
def assertIterEqual(self, expected_iter, actual_iter):
for expected, actual in itertools.izip_longest(expected_iter, actual_iter):
@@ -60,9 +59,11 @@ class LogcatMonitorTest(unittest.TestCase):
with self.assertRaises(StopIteration):
next(expected_iter)
+ @mock.patch('time.sleep', mock.Mock())
def testWaitFor_success(self):
test_log = _CreateTestLog(
raw_logcat=type(self)._TEST_THREADTIME_LOGCAT_DATA)
+ test_log.Start()
actual_match = test_log.WaitFor(r'.*(fatal|error) logcat monitor.*', None)
self.assertTrue(actual_match)
self.assertEqual(
@@ -70,17 +71,27 @@ class LogcatMonitorTest(unittest.TestCase):
'error logcat monitor test message 5',
actual_match.group(0))
self.assertEqual('error', actual_match.group(1))
+ test_log.Stop()
+ test_log.Close()
+ @mock.patch('time.sleep', mock.Mock())
def testWaitFor_failure(self):
test_log = _CreateTestLog(
raw_logcat=type(self)._TEST_THREADTIME_LOGCAT_DATA)
+ test_log.Start()
actual_match = test_log.WaitFor(
r'.*My Success Regex.*', r'.*(fatal|error) logcat monitor.*')
self.assertIsNone(actual_match)
+ test_log.Stop()
+ test_log.Close()
+ @mock.patch('time.sleep', mock.Mock())
def testFindAll_defaults(self):
test_log = _CreateTestLog(
raw_logcat=type(self)._TEST_THREADTIME_LOGCAT_DATA)
+ test_log.Start()
+ test_log.WaitFor(r'.*last line.*', None)
+ test_log.Stop()
expected_results = [
('7890', '0987', 'V', 'LogcatMonitorTest',
'verbose logcat monitor test message 1'),
@@ -96,37 +107,57 @@ class LogcatMonitorTest(unittest.TestCase):
'fatal logcat monitor test message 6')]
actual_results = test_log.FindAll(r'\S* logcat monitor test message \d')
self.assertIterEqual(iter(expected_results), actual_results)
+ test_log.Close()
+ @mock.patch('time.sleep', mock.Mock())
def testFindAll_defaults_miss(self):
test_log = _CreateTestLog(
raw_logcat=type(self)._TEST_THREADTIME_LOGCAT_DATA)
+ test_log.Start()
+ test_log.WaitFor(r'.*last line.*', None)
+ test_log.Stop()
expected_results = []
actual_results = test_log.FindAll(r'\S* nothing should match this \d')
self.assertIterEqual(iter(expected_results), actual_results)
+ test_log.Close()
+ @mock.patch('time.sleep', mock.Mock())
def testFindAll_filterProcId(self):
test_log = _CreateTestLog(
raw_logcat=type(self)._TEST_THREADTIME_LOGCAT_DATA)
+ test_log.Start()
+ test_log.WaitFor(r'.*last line.*', None)
+ test_log.Stop()
actual_results = test_log.FindAll(
r'\S* logcat monitor test message \d', proc_id=1234)
expected_results = [
('1234', '4321', 'E', 'LogcatMonitorTest',
'error logcat monitor test message 5')]
self.assertIterEqual(iter(expected_results), actual_results)
+ test_log.Close()
+ @mock.patch('time.sleep', mock.Mock())
def testFindAll_filterThreadId(self):
test_log = _CreateTestLog(
raw_logcat=type(self)._TEST_THREADTIME_LOGCAT_DATA)
+ test_log.Start()
+ test_log.WaitFor(r'.*last line.*', None)
+ test_log.Stop()
actual_results = test_log.FindAll(
r'\S* logcat monitor test message \d', thread_id=2109)
expected_results = [
('9012', '2109', 'I', 'LogcatMonitorTest',
'info logcat monitor test message 3')]
self.assertIterEqual(iter(expected_results), actual_results)
+ test_log.Close()
+ @mock.patch('time.sleep', mock.Mock())
def testFindAll_filterLogLevel(self):
test_log = _CreateTestLog(
raw_logcat=type(self)._TEST_THREADTIME_LOGCAT_DATA)
+ test_log.Start()
+ test_log.WaitFor(r'.*last line.*', None)
+ test_log.Stop()
actual_results = test_log.FindAll(
r'\S* logcat monitor test message \d', log_level=r'[DW]')
expected_results = [
@@ -135,10 +166,15 @@ class LogcatMonitorTest(unittest.TestCase):
('0123', '3210', 'W', 'LogcatMonitorTest',
'warning logcat monitor test message 4'),]
self.assertIterEqual(iter(expected_results), actual_results)
+ test_log.Close()
+ @mock.patch('time.sleep', mock.Mock())
def testFindAll_filterComponent(self):
test_log = _CreateTestLog(
raw_logcat=type(self)._TEST_THREADTIME_LOGCAT_DATA)
+ test_log.Start()
+ test_log.WaitFor(r'.*last line.*', None)
+ test_log.Stop()
actual_results = test_log.FindAll(r'.*', component='LogcatMonitorTest')
expected_results = [
('7890', '0987', 'V', 'LogcatMonitorTest',
@@ -154,8 +190,9 @@ class LogcatMonitorTest(unittest.TestCase):
('2345', '5432', 'F', 'LogcatMonitorTest',
'fatal logcat monitor test message 6'),
('3456', '6543', 'D', 'LogcatMonitorTest',
- 'ignore me'),]
+ 'last line'),]
self.assertIterEqual(iter(expected_results), actual_results)
+ test_log.Close()
if __name__ == '__main__':
« no previous file with comments | « build/android/devil/android/logcat_monitor.py ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698