Chromium Code Reviews| 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 """Unit tests for instrumentation_test_instance.""" | 6 """Unit tests for instrumentation_test_instance.""" |
| 7 | 7 |
| 8 # pylint: disable=protected-access | 8 # pylint: disable=protected-access |
| 9 | 9 |
| 10 import collections | 10 import collections |
| (...skipping 29 matching lines...) Expand all Loading... | |
| 40 return instrumentation_test_instance.InstrumentationTestInstance( | 40 return instrumentation_test_instance.InstrumentationTestInstance( |
| 41 mock.MagicMock(), mock.MagicMock(), lambda s: None) | 41 mock.MagicMock(), mock.MagicMock(), lambda s: None) |
| 42 | 42 |
| 43 _FlagAttributesArgs = collections.namedtuple( | 43 _FlagAttributesArgs = collections.namedtuple( |
| 44 '_FlagAttributesArgs', | 44 '_FlagAttributesArgs', |
| 45 [ | 45 [ |
| 46 'command_line_flags', | 46 'command_line_flags', |
| 47 'device_flags_file', | 47 'device_flags_file', |
| 48 'strict_mode', | 48 'strict_mode', |
| 49 'regenerate_goldens', | 49 'regenerate_goldens', |
| 50 'test_arguments', | 50 'test_arguments', |
|
shenghuazhang
2017/05/01 19:32:28
I think this arg 'test_arguments' can be removed a
jbudorick
2017/05/01 19:35:53
Done. Nice catch.
| |
| 51 ]) | 51 ]) |
| 52 | 52 |
| 53 def createFlagAttributesArgs( | 53 def createFlagAttributesArgs( |
| 54 self, command_line_flags=None, device_flags_file=None, | 54 self, command_line_flags=None, device_flags_file=None, |
| 55 strict_mode=None, regenerate_goldens=None, test_arguments=None): | 55 strict_mode=None, regenerate_goldens=None, test_arguments=None): |
|
shenghuazhang
2017/05/01 19:32:28
Same here.
jbudorick
2017/05/01 19:35:53
Done.
| |
| 56 return self._FlagAttributesArgs( | 56 return self._FlagAttributesArgs( |
| 57 command_line_flags, device_flags_file, strict_mode, | 57 command_line_flags, device_flags_file, strict_mode, |
| 58 regenerate_goldens, test_arguments) | 58 regenerate_goldens, test_arguments) |
|
shenghuazhang
2017/05/01 19:32:28
And here?
jbudorick
2017/05/01 19:35:53
Done.
| |
| 59 | 59 |
| 60 def test_initializeFlagAttributes_commandLineFlags(self): | 60 def test_initializeFlagAttributes_commandLineFlags(self): |
| 61 o = self.createTestInstance() | 61 o = self.createTestInstance() |
| 62 args = self.createFlagAttributesArgs(command_line_flags=['--foo', '--bar']) | 62 args = self.createFlagAttributesArgs(command_line_flags=['--foo', '--bar']) |
| 63 o._initializeFlagAttributes(args) | 63 o._initializeFlagAttributes(args) |
| 64 self.assertEquals(o._flags, ['--enable-test-intents', '--foo', '--bar']) | 64 self.assertEquals(o._flags, ['--enable-test-intents', '--foo', '--bar']) |
| 65 | 65 |
| 66 def test_initializeFlagAttributes_deviceFlagsFile(self): | 66 def test_initializeFlagAttributes_deviceFlagsFile(self): |
| 67 o = self.createTestInstance() | 67 o = self.createTestInstance() |
| 68 with tempfile.NamedTemporaryFile() as flags_file: | 68 with tempfile.NamedTemporaryFile() as flags_file: |
| (...skipping 16 matching lines...) Expand all Loading... | |
| 85 o._initializeFlagAttributes(args) | 85 o._initializeFlagAttributes(args) |
| 86 self.assertEquals(o._flags, ['--enable-test-intents']) | 86 self.assertEquals(o._flags, ['--enable-test-intents']) |
| 87 | 87 |
| 88 def test_initializeFlagAttributes_regenerateGoldens(self): | 88 def test_initializeFlagAttributes_regenerateGoldens(self): |
| 89 o = self.createTestInstance() | 89 o = self.createTestInstance() |
| 90 args = self.createFlagAttributesArgs(regenerate_goldens=True) | 90 args = self.createFlagAttributesArgs(regenerate_goldens=True) |
| 91 o._initializeFlagAttributes(args) | 91 o._initializeFlagAttributes(args) |
| 92 self.assertEquals( | 92 self.assertEquals( |
| 93 o._flags, ['--enable-test-intents', '--regenerate-goldens']) | 93 o._flags, ['--enable-test-intents', '--regenerate-goldens']) |
| 94 | 94 |
| 95 def test_initializeFlagAttributes_testArgumentsRaisesException(self): | |
| 96 o = self.createTestInstance() | |
| 97 args = self.createFlagAttributesArgs(test_arguments='--foo --bar') | |
| 98 with self.assertRaises(Exception): | |
| 99 o._initializeFlagAttributes(args) | |
| 100 | |
| 101 def testGetTests_noFilter(self): | 95 def testGetTests_noFilter(self): |
| 102 o = self.createTestInstance() | 96 o = self.createTestInstance() |
| 103 raw_tests = [ | 97 raw_tests = [ |
| 104 { | 98 { |
| 105 'annotations': {'Feature': {'value': ['Foo']}}, | 99 'annotations': {'Feature': {'value': ['Foo']}}, |
| 106 'class': 'org.chromium.test.SampleTest', | 100 'class': 'org.chromium.test.SampleTest', |
| 107 'superclass': 'java.lang.Object', | 101 'superclass': 'java.lang.Object', |
| 108 'methods': [ | 102 'methods': [ |
| 109 { | 103 { |
| 110 'annotations': {'SmallTest': None}, | 104 'annotations': {'SmallTest': None}, |
| (...skipping 609 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 720 }), | 714 }), |
| 721 ] | 715 ] |
| 722 results = instrumentation_test_instance.GenerateTestResults( | 716 results = instrumentation_test_instance.GenerateTestResults( |
| 723 None, None, statuses, 0, 1000) | 717 None, None, statuses, 0, 1000) |
| 724 self.assertEqual(1, len(results)) | 718 self.assertEqual(1, len(results)) |
| 725 self.assertEqual(base_test_result.ResultType.SKIP, results[0].GetType()) | 719 self.assertEqual(base_test_result.ResultType.SKIP, results[0].GetType()) |
| 726 | 720 |
| 727 | 721 |
| 728 if __name__ == '__main__': | 722 if __name__ == '__main__': |
| 729 unittest.main(verbosity=2) | 723 unittest.main(verbosity=2) |
| OLD | NEW |