| 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 |
| (...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 137 self.assertEqual(0, code) | 137 self.assertEqual(0, code) |
| 138 self.assertEqual(['hello', 'world', '', ''], result) | 138 self.assertEqual(['hello', 'world', '', ''], result) |
| 139 self.assertEqual([(1, {'class': ['foo'], 'test': ['bar']})], statuses) | 139 self.assertEqual([(1, {'class': ['foo'], 'test': ['bar']})], statuses) |
| 140 | 140 |
| 141 def testGenerateTestResult_noStatus(self): | 141 def testGenerateTestResult_noStatus(self): |
| 142 result = self.instance._GenerateTestResult( | 142 result = self.instance._GenerateTestResult( |
| 143 'test.package.TestClass#testMethod', [], 0, 1000) | 143 'test.package.TestClass#testMethod', [], 0, 1000) |
| 144 self.assertEqual('test.package.TestClass#testMethod', result.GetName()) | 144 self.assertEqual('test.package.TestClass#testMethod', result.GetName()) |
| 145 self.assertEqual(base_test_result.ResultType.UNKNOWN, result.GetType()) | 145 self.assertEqual(base_test_result.ResultType.UNKNOWN, result.GetType()) |
| 146 self.assertEqual('', result.GetLog()) | 146 self.assertEqual('', result.GetLog()) |
| 147 self.assertEqual(1000, result.GetDur()) | 147 self.assertEqual(1000, result.GetDuration()) |
| 148 | 148 |
| 149 def testGenerateTestResult_testPassed(self): | 149 def testGenerateTestResult_testPassed(self): |
| 150 statuses = [ | 150 statuses = [ |
| 151 (1, { | 151 (1, { |
| 152 'class': ['test.package.TestClass'], | 152 'class': ['test.package.TestClass'], |
| 153 'test': ['testMethod'], | 153 'test': ['testMethod'], |
| 154 }), | 154 }), |
| 155 (0, { | 155 (0, { |
| 156 'class': ['test.package.TestClass'], | 156 'class': ['test.package.TestClass'], |
| 157 'test': ['testMethod'], | 157 'test': ['testMethod'], |
| (...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 246 'stack': ['', 'foo/bar.py (27)', 'hello/world.py (42)'], | 246 'stack': ['', 'foo/bar.py (27)', 'hello/world.py (42)'], |
| 247 }), | 247 }), |
| 248 ] | 248 ] |
| 249 result = self.instance._GenerateTestResult( | 249 result = self.instance._GenerateTestResult( |
| 250 'test.package.TestClass#testMethod', statuses, 0, 1000) | 250 'test.package.TestClass#testMethod', statuses, 0, 1000) |
| 251 self.assertEqual(base_test_result.ResultType.CRASH, result.GetType()) | 251 self.assertEqual(base_test_result.ResultType.CRASH, result.GetType()) |
| 252 self.assertEqual('\nfoo/bar.py (27)\nhello/world.py (42)', result.GetLog()) | 252 self.assertEqual('\nfoo/bar.py (27)\nhello/world.py (42)', result.GetLog()) |
| 253 | 253 |
| 254 def test_RunTest_verifyAdbShellCommand(self): | 254 def test_RunTest_verifyAdbShellCommand(self): |
| 255 self.instance.options.test_runner = 'MyTestRunner' | 255 self.instance.options.test_runner = 'MyTestRunner' |
| 256 self.instance.device.RunShellCommand = mock.Mock() | 256 self.instance.device.StartInstrumentation = mock.Mock() |
| 257 self.instance.test_pkg.GetPackageName = mock.Mock( | 257 self.instance.test_pkg.GetPackageName = mock.Mock( |
| 258 return_value='test.package') | 258 return_value='test.package') |
| 259 self.instance._GetInstrumentationArgs = mock.Mock( | 259 self.instance._GetInstrumentationArgs = mock.Mock( |
| 260 return_value={'test_arg_key': 'test_arg_value'}) | 260 return_value={'test_arg_key': 'test_arg_value'}) |
| 261 self.instance._RunTest('test.package.TestClass#testMethod', 100) | 261 self.instance._RunTest('test.package.TestClass#testMethod', 100) |
| 262 self.instance.device.RunShellCommand.assert_called_with( | 262 self.instance.device.StartInstrumentation.assert_called_with( |
| 263 ['am', 'instrument', '-r', | 263 'test.package/MyTestRunner', raw=True, |
| 264 '-e', 'test_arg_key', 'test_arg_value', | 264 extras={ |
| 265 '-e', 'class', 'test.package.TestClass#testMethod', | 265 'test_arg_key': 'test_arg_value', |
| 266 '-w', 'test.package/MyTestRunner'], | 266 'class': 'test.package.TestClass#testMethod' |
| 267 }, |
| 267 timeout=100, retries=0) | 268 timeout=100, retries=0) |
| 268 | 269 |
| 269 if __name__ == '__main__': | 270 if __name__ == '__main__': |
| 270 unittest.main(verbosity=2) | 271 unittest.main(verbosity=2) |
| 271 | 272 |
| OLD | NEW |