| Index: build/android/pylib/instrumentation/instrumentation_test_instance_test.py
|
| diff --git a/build/android/pylib/instrumentation/instrumentation_test_instance_test.py b/build/android/pylib/instrumentation/instrumentation_test_instance_test.py
|
| index 386f2897540856ce982d594c0145abe09675ed2b..a8c85cc26c43bfbfaa70624656d506a442dc7bf8 100755
|
| --- a/build/android/pylib/instrumentation/instrumentation_test_instance_test.py
|
| +++ b/build/android/pylib/instrumentation/instrumentation_test_instance_test.py
|
| @@ -7,6 +7,8 @@
|
|
|
| # pylint: disable=protected-access
|
|
|
| +import collections
|
| +import tempfile
|
| import unittest
|
|
|
| from pylib.base import base_test_result
|
| @@ -38,6 +40,58 @@ class InstrumentationTestInstanceTest(unittest.TestCase):
|
| return instrumentation_test_instance.InstrumentationTestInstance(
|
| mock.MagicMock(), mock.MagicMock(), lambda s: None)
|
|
|
| + _FlagAttributesArgs = collections.namedtuple(
|
| + '_FlagAttributesArgs',
|
| + [
|
| + 'command_line_flags',
|
| + 'device_flags_file',
|
| + 'strict_mode',
|
| + 'regenerate_goldens'
|
| + ])
|
| +
|
| + def createFlagAttributesArgs(
|
| + self, command_line_flags=None, device_flags_file=None,
|
| + strict_mode=None, regenerate_goldens=None):
|
| + return self._FlagAttributesArgs(
|
| + command_line_flags, device_flags_file, strict_mode,
|
| + regenerate_goldens)
|
| +
|
| + def test_initializeFlagAttributes_commandLineFlags(self):
|
| + o = self.createTestInstance()
|
| + args = self.createFlagAttributesArgs(command_line_flags=['--foo', '--bar'])
|
| + o._initializeFlagAttributes(args)
|
| + self.assertEquals(o._flags, ['--enable-test-intents', '--foo', '--bar'])
|
| +
|
| +
|
| + def test_initializeFlagAttributes_deviceFlagsFile(self):
|
| + o = self.createTestInstance()
|
| + with tempfile.NamedTemporaryFile() as flags_file:
|
| + flags_file.write('\n'.join(['--foo', '--bar']))
|
| + flags_file.flush()
|
| +
|
| + args = self.createFlagAttributesArgs(device_flags_file=flags_file.name)
|
| + o._initializeFlagAttributes(args)
|
| + self.assertEquals(o._flags, ['--enable-test-intents', '--foo', '--bar'])
|
| +
|
| + def test_initializeFlagAttributes_strictModeOn(self):
|
| + o = self.createTestInstance()
|
| + args = self.createFlagAttributesArgs(strict_mode='on')
|
| + o._initializeFlagAttributes(args)
|
| + self.assertEquals(o._flags, ['--enable-test-intents', '--strict-mode=on'])
|
| +
|
| + def test_initializeFlagAttributes_strictModeOff(self):
|
| + o = self.createTestInstance()
|
| + args = self.createFlagAttributesArgs(strict_mode='off')
|
| + o._initializeFlagAttributes(args)
|
| + self.assertEquals(o._flags, ['--enable-test-intents'])
|
| +
|
| + def test_initializeFlagAttributes_regenerateGoldens(self):
|
| + o = self.createTestInstance()
|
| + args = self.createFlagAttributesArgs(regenerate_goldens=True)
|
| + o._initializeFlagAttributes(args)
|
| + self.assertEquals(
|
| + o._flags, ['--enable-test-intents', '--regenerate-goldens'])
|
| +
|
| def testGetTests_noFilter(self):
|
| o = self.createTestInstance()
|
| raw_tests = [
|
|
|