OLD | NEW |
1 #!/usr/bin/env python | 1 #!/usr/bin/env python |
2 # Copyright 2014 The Chromium Authors. All rights reserved. | 2 # Copyright 2014 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 | 6 |
7 """Unit tests for instrumentation.TestRunner.""" | 7 """Unit tests for instrumentation.TestRunner.""" |
8 | 8 |
9 # pylint: disable=W0212 | 9 # pylint: disable=W0212 |
10 | 10 |
11 import os | 11 import os |
12 import sys | 12 import sys |
13 import unittest | 13 import unittest |
14 | 14 |
15 from pylib import constants | 15 from pylib import constants |
16 from pylib.base import base_test_result | 16 from pylib.base import base_test_result |
17 from pylib.instrumentation import test_runner | 17 from pylib.instrumentation import test_runner |
18 | 18 |
19 sys.path.append(os.path.join( | 19 sys.path.append(os.path.join( |
20 constants.DIR_SOURCE_ROOT, 'third_party', 'pymock')) | 20 constants.DIR_SOURCE_ROOT, 'third_party', 'pymock')) |
21 import mock # pylint: disable=F0401 | 21 import mock # pylint: disable=F0401 |
22 | 22 |
23 | 23 |
24 class InstrumentationTestRunnerTest(unittest.TestCase): | 24 class InstrumentationTestRunnerTest(unittest.TestCase): |
25 | 25 |
26 def setUp(self): | 26 def setUp(self): |
27 options = mock.Mock() | 27 options = mock.Mock() |
28 options.tool = '' | 28 options.tool = '' |
29 package = mock.Mock() | 29 package = mock.Mock() |
30 self.instance = test_runner.TestRunner(options, None, 0, package) | 30 self.instance = test_runner.TestRunner( |
| 31 options, '123456789abcdef0', 0, package) |
31 | 32 |
32 def testParseAmInstrumentRawOutput_nothing(self): | 33 def testParseAmInstrumentRawOutput_nothing(self): |
33 code, result, statuses = ( | 34 code, result, statuses = ( |
34 test_runner.TestRunner._ParseAmInstrumentRawOutput([''])) | 35 test_runner.TestRunner._ParseAmInstrumentRawOutput([''])) |
35 self.assertEqual(None, code) | 36 self.assertEqual(None, code) |
36 self.assertEqual([], result) | 37 self.assertEqual([], result) |
37 self.assertEqual([], statuses) | 38 self.assertEqual([], statuses) |
38 | 39 |
39 def testParseAmInstrumentRawOutput_noMatchingStarts(self): | 40 def testParseAmInstrumentRawOutput_noMatchingStarts(self): |
40 raw_output = [ | 41 raw_output = [ |
(...skipping 178 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
219 statuses = [ | 220 statuses = [ |
220 (1, { | 221 (1, { |
221 'class': ['test.package.TestClass'], | 222 'class': ['test.package.TestClass'], |
222 'test': ['testMethod'], | 223 'test': ['testMethod'], |
223 }), | 224 }), |
224 (-2, { | 225 (-2, { |
225 'class': ['test.package.TestClass'], | 226 'class': ['test.package.TestClass'], |
226 'test': ['testMethod'], | 227 'test': ['testMethod'], |
227 }), | 228 }), |
228 ] | 229 ] |
| 230 self.instance.device.old_interface.DismissCrashDialogIfNeeded = mock.Mock( |
| 231 return_value=None) |
229 result = self.instance._GenerateTestResult( | 232 result = self.instance._GenerateTestResult( |
230 'test.package.TestClass#testMethod', statuses, 0, 1000) | 233 'test.package.TestClass#testMethod', statuses, 0, 1000) |
231 self.assertEqual(base_test_result.ResultType.FAIL, result.GetType()) | 234 self.assertEqual(base_test_result.ResultType.FAIL, result.GetType()) |
232 | 235 |
233 def testGenerateTestResult_testCrashed(self): | 236 def testGenerateTestResult_testCrashed(self): |
234 self.instance.test_pkg.GetPackageName = mock.Mock( | 237 self.instance.test_pkg.GetPackageName = mock.Mock( |
235 return_value='generate.test.result.test.package') | 238 return_value='generate.test.result.test.package') |
236 self.instance.device.old_interface.DismissCrashDialogIfNeeded = mock.Mock( | 239 self.instance.device.old_interface.DismissCrashDialogIfNeeded = mock.Mock( |
237 return_value='generate.test.result.test.package') | 240 return_value='generate.test.result.test.package') |
238 statuses = [ | 241 statuses = [ |
(...skipping 24 matching lines...) Expand all Loading... |
263 'test.package/MyTestRunner', raw=True, | 266 'test.package/MyTestRunner', raw=True, |
264 extras={ | 267 extras={ |
265 'test_arg_key': 'test_arg_value', | 268 'test_arg_key': 'test_arg_value', |
266 'class': 'test.package.TestClass#testMethod' | 269 'class': 'test.package.TestClass#testMethod' |
267 }, | 270 }, |
268 timeout=100, retries=0) | 271 timeout=100, retries=0) |
269 | 272 |
270 if __name__ == '__main__': | 273 if __name__ == '__main__': |
271 unittest.main(verbosity=2) | 274 unittest.main(verbosity=2) |
272 | 275 |
OLD | NEW |