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

Unified Diff: build/android/pylib/instrumentation/instrumentation_test_instance_test.py

Issue 2743033002: [android] Add support for providing flags to instrumentation tests directly. (Closed)
Patch Set: Created 3 years, 9 months 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
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..c02c3f5e8c855bb370387c1168f0e621782866b4 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,62 @@ class InstrumentationTestInstanceTest(unittest.TestCase):
return instrumentation_test_instance.InstrumentationTestInstance(
mock.MagicMock(), mock.MagicMock(), lambda s: None)
+ _FlagAttributesArgs = collections.namedtuple(
+ '_FlagAttributesArgs',
+ [
+ 'device_flags',
+ 'device_flags_file',
+ 'strict_mode',
+ 'regenerate_goldens'
+ ])
+
+ def createFlagAttributesArgs(
+ self, device_flags=None, device_flags_file=None, strict_mode=None,
+ regenerate_goldens=None):
+ return self._FlagAttributesArgs(
+ device_flags, device_flags_file, strict_mode, regenerate_goldens)
+
+ def test_initializeFlagAttributes_oneDeviceFlag(self):
+ o = self.createTestInstance()
+ args = self.createFlagAttributesArgs(device_flags='--foo')
+ o._initializeFlagAttributes(args)
+ self.assertEquals(o._flags, ['--enable-test-intents', '--foo'])
+
+ def test_initializeFlagAttributes_multipleDeviceFlags(self):
+ o = self.createTestInstance()
+ args = self.createFlagAttributesArgs(device_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 = [

Powered by Google App Engine
This is Rietveld 408576698