Remove ensure_webcam_is_running.py script.

Change-Id: I9e4e35f3e8b3010cbec7b6a6ed2b948072702d66
Bug: b/312914606
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/350564
Reviewed-by: Mirko Bonadei <mbonadei@webrtc.org>
Commit-Queue: Jeremy Leconte <jleconte@google.com>
Reviewed-by: Björn Terelius <terelius@webrtc.org>
Cr-Commit-Position: refs/heads/main@{#42332}
diff --git a/PRESUBMIT.py b/PRESUBMIT.py
index 0f9ac8a..417a8d4 100755
--- a/PRESUBMIT.py
+++ b/PRESUBMIT.py
@@ -52,6 +52,8 @@
     "tools_webrtc/autoroller/roll_deps.py",
     "tools_webrtc/android/build_aar.py",
     "tools_webrtc/ios/build_ios_libs.py",
+    "tools_webrtc/mb/mb.py",
+    "tools_webrtc/mb/mb_unittest.py",
 ]
 
 # These filters will always be removed, even if the caller specifies a filter
diff --git a/infra/specs/gn_isolate_map.pyl b/infra/specs/gn_isolate_map.pyl
index 7e31965..2a3cbdd 100644
--- a/infra/specs/gn_isolate_map.pyl
+++ b/infra/specs/gn_isolate_map.pyl
@@ -126,9 +126,7 @@
   },
   "video_capture_tests": {
     "label": "//modules/video_capture:video_capture_tests",
-    "type": "non_parallel_console_test_launcher",
-    # TODO(bugs.webrtc.org/9292): remove use_webcam and the ensure script.
-    "use_webcam": True,
+    "type": "console_test_launcher",
   },
   "video_codec_perf_tests": {
     "label": "//modules/video_coding:video_codec_perf_tests",
diff --git a/tools_webrtc/ensure_webcam_is_running.py b/tools_webrtc/ensure_webcam_is_running.py
deleted file mode 100755
index 4428d79..0000000
--- a/tools_webrtc/ensure_webcam_is_running.py
+++ /dev/null
@@ -1,103 +0,0 @@
-#!/usr/bin/env vpython3
-
-# Copyright (c) 2014 The WebRTC project authors. All Rights Reserved.
-#
-# Use of this source code is governed by a BSD-style license
-# that can be found in the LICENSE file in the root of the source
-# tree. An additional intellectual property rights grant can be found
-# in the file PATENTS.  All contributing project authors may
-# be found in the AUTHORS file in the root of the source tree.
-"""Checks if a virtual webcam is running and starts it if not.
-
-Returns a non-zero return code if the webcam could not be started.
-
-Prerequisites:
-* The Python interpreter must have the psutil package installed.
-* Windows: a scheduled task named 'ManyCam' must exist and be configured to
-  launch ManyCam preconfigured to auto-play the test clip.
-* Mac: ManyCam must be installed in the default location and be preconfigured
-  to auto-play the test clip.
-* Linux: Not implemented
-
-NOTICE: When running this script as a buildbot step, make sure to set
-usePTY=False for the build step when adding it, or the subprocess will die as
-soon the step has executed.
-
-If any command line arguments are passed to the script, it is executed as a
-command in a subprocess.
-"""
-
-import subprocess
-import sys
-# psutil is not installed on non-Linux machines by default.
-import psutil  # pylint: disable=F0401
-
-WEBCAM_WIN = ('schtasks', '/run', '/tn', 'ManyCam')
-WEBCAM_MAC = ('open', '/Applications/ManyCam/ManyCam.app')
-
-
-def IsWebCamRunning():
-  if sys.platform == 'win32':
-    process_name = 'ManyCam.exe'
-  elif sys.platform.startswith('darwin'):
-    process_name = 'ManyCam'
-  elif sys.platform.startswith('linux'):
-    # TODO(bugs.webrtc.org/9636): Currently a no-op on Linux: sw webcams no
-    # longer in use.
-    print('Virtual webcam: no-op on Linux')
-    return True
-  else:
-    raise Exception('Unsupported platform: %s' % sys.platform)
-  for p in psutil.process_iter():
-    try:
-      if process_name == p.name:
-        print('Found a running virtual webcam (%s with PID %s)' %
-              (p.name, p.pid))
-        return True
-    except psutil.AccessDenied:
-      pass  # This is normal if we query sys processes, etc.
-  return False
-
-
-def StartWebCam():
-  try:
-    if sys.platform == 'win32':
-      subprocess.check_call(WEBCAM_WIN)
-      print('Successfully launched virtual webcam.')
-    elif sys.platform.startswith('darwin'):
-      subprocess.check_call(WEBCAM_MAC)
-      print('Successfully launched virtual webcam.')
-    elif sys.platform.startswith('linux'):
-      # TODO(bugs.webrtc.org/9636): Currently a no-op on Linux: sw webcams no
-      # longer in use.
-      print('Not implemented on Linux')
-
-  except Exception as e:
-    print('Failed to launch virtual webcam: %s' % e)
-    return False
-
-  return True
-
-
-def _ForcePythonInterpreter(cmd):
-  """Returns the fixed command line to call the right python executable."""
-  out = cmd[:]
-  if out[0] == 'vpython3':
-    out[0] = sys.executable
-  elif out[0].endswith('.py'):
-    out.insert(0, sys.executable)
-  return out
-
-
-def Main(argv):
-  if not IsWebCamRunning():
-    if not StartWebCam():
-      return 1
-
-  if argv:
-    return subprocess.call(_ForcePythonInterpreter(argv))
-  return 0
-
-
-if __name__ == '__main__':
-  sys.exit(Main(sys.argv[1:]))
diff --git a/tools_webrtc/mb/mb.py b/tools_webrtc/mb/mb.py
index c23e69c..9d063cb 100755
--- a/tools_webrtc/mb/mb.py
+++ b/tools_webrtc/mb/mb.py
@@ -25,132 +25,133 @@
 
 
 def _GetExecutable(target, platform):
-  executable_prefix = '.\\' if platform == 'win32' else './'
-  executable_suffix = '.exe' if platform == 'win32' else ''
-  return executable_prefix + target + executable_suffix
+    executable_prefix = '.\\' if platform == 'win32' else './'
+    executable_suffix = '.exe' if platform == 'win32' else ''
+    return executable_prefix + target + executable_suffix
 
 
 def main(args):
-  mbw = WebRTCMetaBuildWrapper()
-  return mbw.Main(args)
+    mbw = WebRTCMetaBuildWrapper()
+    return mbw.Main(args)
 
 
 class WebRTCMetaBuildWrapper(mb.MetaBuildWrapper):
-  def __init__(self):
-    super().__init__()
-    # Make sure default_config and default_isolate_map are attributes of the
-    # parent class before changing their values.
-    # pylint: disable=access-member-before-definition
-    assert self.default_config
-    assert self.default_isolate_map
-    self.default_config = os.path.join(_SCRIPT_DIR, 'mb_config.pyl')
-    self.default_isolate_map = os.path.join(_SRC_DIR, 'infra', 'specs',
-                                            'gn_isolate_map.pyl')
 
-  def GetSwarmingCommand(self, target, vals):
-    isolate_map = self.ReadIsolateMap()
-    test_type = isolate_map[target]['type']
+    def __init__(self):
+        super().__init__()
+        # Make sure default_config and default_isolate_map are attributes of the
+        # parent class before changing their values.
+        # pylint: disable=access-member-before-definition
+        assert self.default_config
+        assert self.default_isolate_map
+        self.default_config = os.path.join(_SCRIPT_DIR, 'mb_config.pyl')
+        self.default_isolate_map = os.path.join(_SRC_DIR, 'infra', 'specs',
+                                                'gn_isolate_map.pyl')
 
-    is_android = 'target_os="android"' in vals['gn_args']
-    is_fuchsia = 'target_os="fuchsia"' in vals['gn_args']
-    is_ios = 'target_os="ios"' in vals['gn_args']
-    is_linux = self.platform.startswith('linux') and not is_android
-    is_win = self.platform.startswith('win')
+    def GetSwarmingCommand(self, target, vals):
+        isolate_map = self.ReadIsolateMap()
+        test_type = isolate_map[target]['type']
 
-    if test_type == 'nontest':
-      self.WriteFailureAndRaise('We should not be isolating %s.' % target,
-                                output_path=None)
-    if test_type not in ('console_test_launcher', 'windowed_test_launcher',
-                         'non_parallel_console_test_launcher', 'raw',
-                         'additional_compile_target', 'junit_test', 'script'):
-      self.WriteFailureAndRaise('No command line for '
-                                '%s found (test type %s).' %
-                                (target, test_type),
-                                output_path=None)
+        is_android = 'target_os="android"' in vals['gn_args']
+        is_fuchsia = 'target_os="fuchsia"' in vals['gn_args']
+        is_ios = 'target_os="ios"' in vals['gn_args']
+        is_linux = self.platform.startswith('linux') and not is_android
+        is_win = self.platform.startswith('win')
 
-    cmdline = []
-    extra_files = [
-        '../../.vpython3',
-        '../../testing/test_env.py',
-    ]
-    vpython_exe = 'vpython3'
+        if test_type == 'nontest':
+            self.WriteFailureAndRaise('We should not be isolating %s.' %
+                                      target,
+                                      output_path=None)
+        if test_type not in ('console_test_launcher', 'windowed_test_launcher',
+                             'non_parallel_console_test_launcher', 'raw',
+                             'additional_compile_target', 'junit_test',
+                             'script'):
+            self.WriteFailureAndRaise('No command line for '
+                                      '%s found (test type %s).' %
+                                      (target, test_type),
+                                      output_path=None)
 
-    if isolate_map[target].get('script'):
-      cmdline += [
-          vpython_exe,
-          '../../' + self.ToSrcRelPath(isolate_map[target]['script'])
-      ]
-    elif is_android:
-      cmdline += [
-          'luci-auth', 'context', '--', vpython_exe,
-          '../../build/android/test_wrapper/logdog_wrapper.py', '--target',
-          target, '--logdog-bin-cmd',
-          '../../.task_template_packages/logdog_butler', '--logcat-output-file',
-          '${ISOLATED_OUTDIR}/logcats', '--store-tombstones'
-      ]
-    elif is_ios or is_fuchsia or test_type == 'raw':
-      if is_win:
-        cmdline += ['bin\\run_{}.bat'.format(target)]
-      else:
-        cmdline += ['bin/run_{}'.format(target)]
-    else:
-      if isolate_map[target].get('use_webcam', False):
-        cmdline += [
-            vpython_exe, '../../tools_webrtc/ensure_webcam_is_running.py'
+        cmdline = []
+        extra_files = [
+            '../../.vpython3',
+            '../../testing/test_env.py',
         ]
-        extra_files.append('../../tools_webrtc/ensure_webcam_is_running.py')
-      if isolate_map[target].get('use_pipewire', False):
-        cmdline += [vpython_exe, '../../tools_webrtc/configure_pipewire.py']
-        extra_files.append('../../tools_webrtc/configure_pipewire.py')
+        vpython_exe = 'vpython3'
 
-      # is_linux uses use_ozone and x11 by default.
-      use_x11 = is_linux
+        if isolate_map[target].get('script'):
+            cmdline += [
+                vpython_exe,
+                '../../' + self.ToSrcRelPath(isolate_map[target]['script'])
+            ]
+        elif is_android:
+            cmdline += [
+                'luci-auth', 'context', '--', vpython_exe,
+                '../../build/android/test_wrapper/logdog_wrapper.py',
+                '--target', target, '--logdog-bin-cmd',
+                '../../.task_template_packages/logdog_butler',
+                '--logcat-output-file', '${ISOLATED_OUTDIR}/logcats',
+                '--store-tombstones'
+            ]
+        elif is_ios or is_fuchsia or test_type == 'raw':
+            if is_win:
+                cmdline += ['bin\\run_{}.bat'.format(target)]
+            else:
+                cmdline += ['bin/run_{}'.format(target)]
+        else:
+            if isolate_map[target].get('use_pipewire', False):
+                cmdline += [
+                    vpython_exe, '../../tools_webrtc/configure_pipewire.py'
+                ]
+                extra_files.append('../../tools_webrtc/configure_pipewire.py')
 
-      xvfb = use_x11 and test_type == 'windowed_test_launcher'
-      if xvfb:
-        cmdline += [vpython_exe, '../../testing/xvfb.py']
-        extra_files.append('../../testing/xvfb.py')
-      else:
-        cmdline += [vpython_exe, '../../testing/test_env.py']
+            # is_linux uses use_ozone and x11 by default.
+            use_x11 = is_linux
 
-      extra_files += [
-          '../../third_party/gtest-parallel/gtest-parallel',
-          '../../third_party/gtest-parallel/gtest_parallel.py',
-          '../../tools_webrtc/gtest-parallel-wrapper.py',
-      ]
-      output_dir = '${ISOLATED_OUTDIR}/test_logs'
-      cmdline += [
-          '../../tools_webrtc/gtest-parallel-wrapper.py',
-          '--output_dir=%s' % output_dir,
-          '--gtest_color=no',
-      ]
-      if test_type == 'non_parallel_console_test_launcher':
-        # Still use the gtest-parallel-wrapper.py script since we
-        # need it to run tests on swarming, but don't execute tests
-        # in parallel.
-        cmdline.append('--workers=1')
+            xvfb = use_x11 and test_type == 'windowed_test_launcher'
+            if xvfb:
+                cmdline += [vpython_exe, '../../testing/xvfb.py']
+                extra_files.append('../../testing/xvfb.py')
+            else:
+                cmdline += [vpython_exe, '../../testing/test_env.py']
 
-      asan = 'is_asan=true' in vals['gn_args']
-      lsan = 'is_lsan=true' in vals['gn_args']
-      msan = 'is_msan=true' in vals['gn_args']
-      tsan = 'is_tsan=true' in vals['gn_args']
-      sanitizer = asan or lsan or msan or tsan
-      if not sanitizer:
-        # Retry would hide most sanitizers detections.
-        cmdline.append('--retry_failed=3')
+            extra_files += [
+                '../../third_party/gtest-parallel/gtest-parallel',
+                '../../third_party/gtest-parallel/gtest_parallel.py',
+                '../../tools_webrtc/gtest-parallel-wrapper.py',
+            ]
+            output_dir = '${ISOLATED_OUTDIR}/test_logs'
+            cmdline += [
+                '../../tools_webrtc/gtest-parallel-wrapper.py',
+                '--output_dir=%s' % output_dir,
+                '--gtest_color=no',
+            ]
+            if test_type == 'non_parallel_console_test_launcher':
+                # Still use the gtest-parallel-wrapper.py script since we
+                # need it to run tests on swarming, but don't execute tests
+                # in parallel.
+                cmdline.append('--workers=1')
 
-      cmdline.append(_GetExecutable(target, self.platform))
+            asan = 'is_asan=true' in vals['gn_args']
+            lsan = 'is_lsan=true' in vals['gn_args']
+            msan = 'is_msan=true' in vals['gn_args']
+            tsan = 'is_tsan=true' in vals['gn_args']
+            sanitizer = asan or lsan or msan or tsan
+            if not sanitizer:
+                # Retry would hide most sanitizers detections.
+                cmdline.append('--retry_failed=3')
 
-      cmdline.extend([
-          '--asan=%d' % asan,
-          '--lsan=%d' % lsan,
-          '--msan=%d' % msan,
-          '--tsan=%d' % tsan,
-      ])
+            cmdline.append(_GetExecutable(target, self.platform))
 
-    cmdline += isolate_map[target].get('args', [])
+            cmdline.extend([
+                '--asan=%d' % asan,
+                '--lsan=%d' % lsan,
+                '--msan=%d' % msan,
+                '--tsan=%d' % tsan,
+            ])
 
-    return cmdline, extra_files
+        cmdline += isolate_map[target].get('args', [])
+
+        return cmdline, extra_files
 
 if __name__ == '__main__':
-  sys.exit(main(sys.argv[1:]))
+    sys.exit(main(sys.argv[1:]))
diff --git a/tools_webrtc/mb/mb_unittest.py b/tools_webrtc/mb/mb_unittest.py
index 583fefd..f0ddb2e 100755
--- a/tools_webrtc/mb/mb_unittest.py
+++ b/tools_webrtc/mb/mb_unittest.py
@@ -25,134 +25,137 @@
 
 
 class FakeMBW(mb.WebRTCMetaBuildWrapper):
-  def __init__(self, win32=False):
-    super().__init__()
 
-    # Override vars for test portability.
-    if win32:
-      self.chromium_src_dir = 'c:\\fake_src'
-      self.default_config = 'c:\\fake_src\\tools_webrtc\\mb\\mb_config.pyl'
-      self.default_isolate_map = ('c:\\fake_src\\testing\\buildbot\\'
-                                  'gn_isolate_map.pyl')
-      self.platform = 'win32'
-      self.executable = 'c:\\python\\vpython3.exe'
-      self.sep = '\\'
-      self.cwd = 'c:\\fake_src\\out\\Default'
-    else:
-      self.chromium_src_dir = '/fake_src'
-      self.default_config = '/fake_src/tools_webrtc/mb/mb_config.pyl'
-      self.default_isolate_map = '/fake_src/testing/buildbot/gn_isolate_map.pyl'
-      self.executable = '/usr/bin/vpython3'
-      self.platform = 'linux2'
-      self.sep = '/'
-      self.cwd = '/fake_src/out/Default'
+    def __init__(self, win32=False):
+        super().__init__()
 
-    self.files = {}
-    self.dirs = set()
-    self.calls = []
-    self.cmds = []
-    self.cross_compile = None
-    self.out = ''
-    self.err = ''
-    self.rmdirs = []
+        # Override vars for test portability.
+        if win32:
+            self.chromium_src_dir = 'c:\\fake_src'
+            self.default_config = (
+                'c:\\fake_src\\tools_webrtc\\mb\\mb_config.pyl')
+            self.default_isolate_map = ('c:\\fake_src\\testing\\buildbot\\'
+                                        'gn_isolate_map.pyl')
+            self.platform = 'win32'
+            self.executable = 'c:\\python\\vpython3.exe'
+            self.sep = '\\'
+            self.cwd = 'c:\\fake_src\\out\\Default'
+        else:
+            self.chromium_src_dir = '/fake_src'
+            self.default_config = '/fake_src/tools_webrtc/mb/mb_config.pyl'
+            self.default_isolate_map = (
+                '/fake_src/testing/buildbot/gn_isolate_map.pyl')
+            self.executable = '/usr/bin/vpython3'
+            self.platform = 'linux2'
+            self.sep = '/'
+            self.cwd = '/fake_src/out/Default'
 
-  def ExpandUser(self, path):
-    # pylint: disable=no-self-use
-    return '$HOME/%s' % path
+        self.files = {}
+        self.dirs = set()
+        self.calls = []
+        self.cmds = []
+        self.cross_compile = None
+        self.out = ''
+        self.err = ''
+        self.rmdirs = []
 
-  def Exists(self, path):
-    abs_path = self._AbsPath(path)
-    return self.files.get(abs_path) is not None or abs_path in self.dirs
+    def ExpandUser(self, path):
+        # pylint: disable=no-self-use
+        return '$HOME/%s' % path
 
-  def ListDir(self, path):
-    dir_contents = []
-    for f in list(self.files.keys()) + list(self.dirs):
-      head, _ = os.path.split(f)
-      if head == path:
-        dir_contents.append(f)
-    return dir_contents
+    def Exists(self, path):
+        abs_path = self._AbsPath(path)
+        return self.files.get(abs_path) is not None or abs_path in self.dirs
 
-  def MaybeMakeDirectory(self, path):
-    abpath = self._AbsPath(path)
-    self.dirs.add(abpath)
+    def ListDir(self, path):
+        dir_contents = []
+        for f in list(self.files.keys()) + list(self.dirs):
+            head, _ = os.path.split(f)
+            if head == path:
+                dir_contents.append(f)
+        return dir_contents
 
-  def PathJoin(self, *comps):
-    return self.sep.join(comps)
+    def MaybeMakeDirectory(self, path):
+        abpath = self._AbsPath(path)
+        self.dirs.add(abpath)
 
-  def ReadFile(self, path):
-    try:
-      return self.files[self._AbsPath(path)]
-    except KeyError as e:
-      raise IOError('%s not found' % path) from e
+    def PathJoin(self, *comps):
+        return self.sep.join(comps)
 
-  def WriteFile(self, path, contents, force_verbose=False):
-    if self.args.dryrun or self.args.verbose or force_verbose:
-      self.Print('\nWriting """\\\n%s""" to %s.\n' % (contents, path))
-    abpath = self._AbsPath(path)
-    self.files[abpath] = contents
+    def ReadFile(self, path):
+        try:
+            return self.files[self._AbsPath(path)]
+        except KeyError as e:
+            raise IOError('%s not found' % path) from e
 
-  def Call(self, cmd, env=None, capture_output=True, input=None):
-    # pylint: disable=redefined-builtin
-    del env
-    del capture_output
-    del input
-    self.calls.append(cmd)
-    if self.cmds:
-      return self.cmds.pop(0)
-    return 0, '', ''
+    def WriteFile(self, path, contents, force_verbose=False):
+        if self.args.dryrun or self.args.verbose or force_verbose:
+            self.Print('\nWriting """\\\n%s""" to %s.\n' % (contents, path))
+        abpath = self._AbsPath(path)
+        self.files[abpath] = contents
 
-  def Print(self, *args, **kwargs):
-    sep = kwargs.get('sep', ' ')
-    end = kwargs.get('end', '\n')
-    f = kwargs.get('file', sys.stdout)
-    if f == sys.stderr:
-      self.err += sep.join(args) + end
-    else:
-      self.out += sep.join(args) + end
+    def Call(self, cmd, env=None, capture_output=True, input=None):
+        # pylint: disable=redefined-builtin
+        del env
+        del capture_output
+        del input
+        self.calls.append(cmd)
+        if self.cmds:
+            return self.cmds.pop(0)
+        return 0, '', ''
 
-  def TempDir(self):
-    tmp_dir = os.path.join(tempfile.gettempdir(), 'mb_test')
-    self.dirs.add(tmp_dir)
-    return tmp_dir
+    def Print(self, *args, **kwargs):
+        sep = kwargs.get('sep', ' ')
+        end = kwargs.get('end', '\n')
+        f = kwargs.get('file', sys.stdout)
+        if f == sys.stderr:
+            self.err += sep.join(args) + end
+        else:
+            self.out += sep.join(args) + end
 
-  def TempFile(self, mode='w'):
-    del mode
-    return FakeFile(self.files)
+    def TempDir(self):
+        tmp_dir = os.path.join(tempfile.gettempdir(), 'mb_test')
+        self.dirs.add(tmp_dir)
+        return tmp_dir
 
-  def RemoveFile(self, path):
-    abpath = self._AbsPath(path)
-    self.files[abpath] = None
+    def TempFile(self, mode='w'):
+        del mode
+        return FakeFile(self.files)
 
-  def RemoveDirectory(self, abs_path):
-    # Normalize the passed-in path to handle different working directories
-    # used during unit testing.
-    abs_path = self._AbsPath(abs_path)
-    self.rmdirs.append(abs_path)
-    files_to_delete = [f for f in self.files if f.startswith(abs_path)]
-    for f in files_to_delete:
-      self.files[f] = None
+    def RemoveFile(self, path):
+        abpath = self._AbsPath(path)
+        self.files[abpath] = None
 
-  def _AbsPath(self, path):
-    if not ((self.platform == 'win32' and path.startswith('c:')) or
-            (self.platform != 'win32' and path.startswith('/'))):
-      path = self.PathJoin(self.cwd, path)
-    if self.sep == '\\':
-      return re.sub(r'\\+', r'\\', path)
-    return re.sub('/+', '/', path)
+    def RemoveDirectory(self, abs_path):
+        # Normalize the passed-in path to handle different working directories
+        # used during unit testing.
+        abs_path = self._AbsPath(abs_path)
+        self.rmdirs.append(abs_path)
+        files_to_delete = [f for f in self.files if f.startswith(abs_path)]
+        for f in files_to_delete:
+            self.files[f] = None
+
+    def _AbsPath(self, path):
+        if not ((self.platform == 'win32' and path.startswith('c:')) or
+                (self.platform != 'win32' and path.startswith('/'))):
+            path = self.PathJoin(self.cwd, path)
+        if self.sep == '\\':
+            return re.sub(r'\\+', r'\\', path)
+        return re.sub('/+', '/', path)
 
 
 class FakeFile:
-  # pylint: disable=invalid-name
-  def __init__(self, files):
-    self.name = '/tmp/file'
-    self.buf = ''
-    self.files = files
+    # pylint: disable=invalid-name
+    def __init__(self, files):
+        self.name = '/tmp/file'
+        self.buf = ''
+        self.files = files
 
-  def write(self, contents):
-    self.buf += contents
+    def write(self, contents):
+        self.buf += contents
 
-  def close(self):
-    self.files[self.name] = self.buf
+    def close(self):
+        self.files[self.name] = self.buf
 
 
 TEST_CONFIG = """\
@@ -213,516 +216,480 @@
 
 
 def CreateFakeMBW(files=None, win32=False):
-  mbw = FakeMBW(win32=win32)
-  mbw.files.setdefault(mbw.default_config, TEST_CONFIG)
-  mbw.files.setdefault(
-      mbw.ToAbsPath('//testing/buildbot/gn_isolate_map.pyl'), '''{
+    mbw = FakeMBW(win32=win32)
+    mbw.files.setdefault(mbw.default_config, TEST_CONFIG)
+    mbw.files.setdefault(
+        mbw.ToAbsPath('//testing/buildbot/gn_isolate_map.pyl'), '''{
       "foo_unittests": {
         "label": "//foo:foo_unittests",
         "type": "console_test_launcher",
         "args": [],
       },
     }''')
-  mbw.files.setdefault(
-      mbw.ToAbsPath('//build/args/bots/fake_group/fake_args_bot.gn'),
-      'is_debug = false\ndcheck_always_on=false\n')
-  mbw.files.setdefault(mbw.ToAbsPath('//tools/mb/rts_banned_suites.json'), '{}')
-  if files:
-    for path, contents in list(files.items()):
-      mbw.files[path] = contents
-      if path.endswith('.runtime_deps'):
+    mbw.files.setdefault(
+        mbw.ToAbsPath('//build/args/bots/fake_group/fake_args_bot.gn'),
+        'is_debug = false\ndcheck_always_on=false\n')
+    mbw.files.setdefault(mbw.ToAbsPath('//tools/mb/rts_banned_suites.json'),
+                         '{}')
+    if files:
+        for path, contents in list(files.items()):
+            mbw.files[path] = contents
+            if path.endswith('.runtime_deps'):
 
-        def FakeCall(cmd, env=None, capture_output=True, stdin=None):
-          # pylint: disable=cell-var-from-loop
-          del cmd
-          del env
-          del capture_output
-          del stdin
-          mbw.files[path] = contents
-          return 0, '', ''
+                def FakeCall(cmd, env=None, capture_output=True, stdin=None):
+                    # pylint: disable=cell-var-from-loop
+                    del cmd
+                    del env
+                    del capture_output
+                    del stdin
+                    mbw.files[path] = contents
+                    return 0, '', ''
 
-        # pylint: disable=invalid-name
-        mbw.Call = FakeCall
-  return mbw
+                # pylint: disable=invalid-name
+                mbw.Call = FakeCall
+    return mbw
 
 
 class UnitTest(unittest.TestCase):
-  # pylint: disable=invalid-name
-  def check(self,
-            args,
-            mbw=None,
-            files=None,
-            out=None,
-            err=None,
-            ret=None,
-            env=None):
-    if not mbw:
-      mbw = CreateFakeMBW(files)
+    # pylint: disable=invalid-name
+    def check(self,
+              args,
+              mbw=None,
+              files=None,
+              out=None,
+              err=None,
+              ret=None,
+              env=None):
+        if not mbw:
+            mbw = CreateFakeMBW(files)
 
-    try:
-      prev_env = os.environ.copy()
-      os.environ = env if env else prev_env
-      actual_ret = mbw.Main(args)
-    finally:
-      os.environ = prev_env
-    self.assertEqual(
-        actual_ret, ret,
-        "ret: %s, out: %s, err: %s" % (actual_ret, mbw.out, mbw.err))
-    if out is not None:
-      self.assertEqual(mbw.out, out)
-    if err is not None:
-      self.assertEqual(mbw.err, err)
-    return mbw
+        try:
+            prev_env = os.environ.copy()
+            os.environ = env if env else prev_env
+            actual_ret = mbw.Main(args)
+        finally:
+            os.environ = prev_env
+        self.assertEqual(
+            actual_ret, ret,
+            "ret: %s, out: %s, err: %s" % (actual_ret, mbw.out, mbw.err))
+        if out is not None:
+            self.assertEqual(mbw.out, out)
+        if err is not None:
+            self.assertEqual(mbw.err, err)
+        return mbw
 
-  def test_gen_swarming(self):
-    files = {
-        '/tmp/swarming_targets':
-        'foo_unittests\n',
-        '/fake_src/testing/buildbot/gn_isolate_map.pyl':
-        ("{'foo_unittests': {"
-         "  'label': '//foo:foo_unittests',"
-         "  'type': 'raw',"
-         "  'args': [],"
-         "}}\n"),
-        '/fake_src/out/Default/foo_unittests.runtime_deps': ("foo_unittests\n"),
-    }
-    mbw = CreateFakeMBW(files)
-    self.check([
-        'gen', '-c', 'debug_goma', '--swarming-targets-file',
-        '/tmp/swarming_targets', '//out/Default'
-    ],
-               mbw=mbw,
-               ret=0)
-    self.assertIn('/fake_src/out/Default/foo_unittests.isolate', mbw.files)
-    self.assertIn('/fake_src/out/Default/foo_unittests.isolated.gen.json',
-                  mbw.files)
+    def test_gen_swarming(self):
+        files = {
+            '/tmp/swarming_targets':
+            'foo_unittests\n',
+            '/fake_src/testing/buildbot/gn_isolate_map.pyl':
+            ("{'foo_unittests': {"
+             "  'label': '//foo:foo_unittests',"
+             "  'type': 'raw',"
+             "  'args': [],"
+             "}}\n"),
+            '/fake_src/out/Default/foo_unittests.runtime_deps':
+            ("foo_unittests\n"),
+        }
+        mbw = CreateFakeMBW(files)
+        self.check([
+            'gen', '-c', 'debug_goma', '--swarming-targets-file',
+            '/tmp/swarming_targets', '//out/Default'
+        ],
+                   mbw=mbw,
+                   ret=0)
+        self.assertIn('/fake_src/out/Default/foo_unittests.isolate', mbw.files)
+        self.assertIn('/fake_src/out/Default/foo_unittests.isolated.gen.json',
+                      mbw.files)
 
-  def test_gen_swarming_android(self):
-    test_files = {
-        '/tmp/swarming_targets':
-        'foo_unittests\n',
-        '/fake_src/testing/buildbot/gn_isolate_map.pyl':
-        ("{'foo_unittests': {"
-         "  'label': '//foo:foo_unittests',"
-         "  'type': 'console_test_launcher',"
-         "}}\n"),
-        '/fake_src/out/Default/foo_unittests.runtime_deps': ("foo_unittests\n"),
-    }
-    mbw = self.check([
-        'gen', '-c', 'android_bot', '//out/Default', '--swarming-targets-file',
-        '/tmp/swarming_targets', '--isolate-map-file',
-        '/fake_src/testing/buildbot/gn_isolate_map.pyl'
-    ],
-                     files=test_files,
-                     ret=0)
+    def test_gen_swarming_android(self):
+        test_files = {
+            '/tmp/swarming_targets':
+            'foo_unittests\n',
+            '/fake_src/testing/buildbot/gn_isolate_map.pyl':
+            ("{'foo_unittests': {"
+             "  'label': '//foo:foo_unittests',"
+             "  'type': 'console_test_launcher',"
+             "}}\n"),
+            '/fake_src/out/Default/foo_unittests.runtime_deps':
+            ("foo_unittests\n"),
+        }
+        mbw = self.check([
+            'gen', '-c', 'android_bot', '//out/Default',
+            '--swarming-targets-file', '/tmp/swarming_targets',
+            '--isolate-map-file',
+            '/fake_src/testing/buildbot/gn_isolate_map.pyl'
+        ],
+                         files=test_files,
+                         ret=0)
 
-    isolate_file = mbw.files['/fake_src/out/Default/foo_unittests.isolate']
-    isolate_file_contents = ast.literal_eval(isolate_file)
-    files = isolate_file_contents['variables']['files']
-    command = isolate_file_contents['variables']['command']
+        isolate_file = mbw.files['/fake_src/out/Default/foo_unittests.isolate']
+        isolate_file_contents = ast.literal_eval(isolate_file)
+        files = isolate_file_contents['variables']['files']
+        command = isolate_file_contents['variables']['command']
 
-    self.assertEqual(
-        files,
-        ['../../.vpython3', '../../testing/test_env.py', 'foo_unittests'])
-    self.assertEqual(command, [
-        'luci-auth',
-        'context',
-        '--',
-        'vpython3',
-        '../../build/android/test_wrapper/logdog_wrapper.py',
-        '--target',
-        'foo_unittests',
-        '--logdog-bin-cmd',
-        '../../.task_template_packages/logdog_butler',
-        '--logcat-output-file',
-        '${ISOLATED_OUTDIR}/logcats',
-        '--store-tombstones',
-    ])
+        self.assertEqual(
+            files,
+            ['../../.vpython3', '../../testing/test_env.py', 'foo_unittests'])
+        self.assertEqual(command, [
+            'luci-auth',
+            'context',
+            '--',
+            'vpython3',
+            '../../build/android/test_wrapper/logdog_wrapper.py',
+            '--target',
+            'foo_unittests',
+            '--logdog-bin-cmd',
+            '../../.task_template_packages/logdog_butler',
+            '--logcat-output-file',
+            '${ISOLATED_OUTDIR}/logcats',
+            '--store-tombstones',
+        ])
 
-  def test_gen_swarming_android_junit_test(self):
-    test_files = {
-        '/tmp/swarming_targets':
-        'foo_unittests\n',
-        '/fake_src/testing/buildbot/gn_isolate_map.pyl':
-        ("{'foo_unittests': {"
-         "  'label': '//foo:foo_unittests',"
-         "  'type': 'junit_test',"
-         "}}\n"),
-        '/fake_src/out/Default/foo_unittests.runtime_deps': ("foo_unittests\n"),
-    }
-    mbw = self.check([
-        'gen', '-c', 'android_bot', '//out/Default', '--swarming-targets-file',
-        '/tmp/swarming_targets', '--isolate-map-file',
-        '/fake_src/testing/buildbot/gn_isolate_map.pyl'
-    ],
-                     files=test_files,
-                     ret=0)
+    def test_gen_swarming_android_junit_test(self):
+        test_files = {
+            '/tmp/swarming_targets':
+            'foo_unittests\n',
+            '/fake_src/testing/buildbot/gn_isolate_map.pyl':
+            ("{'foo_unittests': {"
+             "  'label': '//foo:foo_unittests',"
+             "  'type': 'junit_test',"
+             "}}\n"),
+            '/fake_src/out/Default/foo_unittests.runtime_deps':
+            ("foo_unittests\n"),
+        }
+        mbw = self.check([
+            'gen', '-c', 'android_bot', '//out/Default',
+            '--swarming-targets-file', '/tmp/swarming_targets',
+            '--isolate-map-file',
+            '/fake_src/testing/buildbot/gn_isolate_map.pyl'
+        ],
+                         files=test_files,
+                         ret=0)
 
-    isolate_file = mbw.files['/fake_src/out/Default/foo_unittests.isolate']
-    isolate_file_contents = ast.literal_eval(isolate_file)
-    files = isolate_file_contents['variables']['files']
-    command = isolate_file_contents['variables']['command']
+        isolate_file = mbw.files['/fake_src/out/Default/foo_unittests.isolate']
+        isolate_file_contents = ast.literal_eval(isolate_file)
+        files = isolate_file_contents['variables']['files']
+        command = isolate_file_contents['variables']['command']
 
-    self.assertEqual(
-        files,
-        ['../../.vpython3', '../../testing/test_env.py', 'foo_unittests'])
-    self.assertEqual(command, [
-        'luci-auth',
-        'context',
-        '--',
-        'vpython3',
-        '../../build/android/test_wrapper/logdog_wrapper.py',
-        '--target',
-        'foo_unittests',
-        '--logdog-bin-cmd',
-        '../../.task_template_packages/logdog_butler',
-        '--logcat-output-file',
-        '${ISOLATED_OUTDIR}/logcats',
-        '--store-tombstones',
-    ])
+        self.assertEqual(
+            files,
+            ['../../.vpython3', '../../testing/test_env.py', 'foo_unittests'])
+        self.assertEqual(command, [
+            'luci-auth',
+            'context',
+            '--',
+            'vpython3',
+            '../../build/android/test_wrapper/logdog_wrapper.py',
+            '--target',
+            'foo_unittests',
+            '--logdog-bin-cmd',
+            '../../.task_template_packages/logdog_butler',
+            '--logcat-output-file',
+            '${ISOLATED_OUTDIR}/logcats',
+            '--store-tombstones',
+        ])
 
-  def test_gen_script(self):
-    test_files = {
-        '/tmp/swarming_targets':
-        'foo_unittests_script\n',
-        '/fake_src/testing/buildbot/gn_isolate_map.pyl':
-        ("{'foo_unittests_script': {"
-         "  'label': '//foo:foo_unittests',"
-         "  'type': 'script',"
-         "  'script': '//foo/foo_unittests_script.py',"
-         "}}\n"),
-        '/fake_src/out/Default/foo_unittests_script.runtime_deps':
-        ("foo_unittests\n"
-         "foo_unittests_script.py\n"),
-    }
-    mbw = self.check([
-        'gen', '-c', 'debug_goma', '//out/Default', '--swarming-targets-file',
-        '/tmp/swarming_targets', '--isolate-map-file',
-        '/fake_src/testing/buildbot/gn_isolate_map.pyl'
-    ],
-                     files=test_files,
-                     ret=0)
+    def test_gen_script(self):
+        test_files = {
+            '/tmp/swarming_targets':
+            'foo_unittests_script\n',
+            '/fake_src/testing/buildbot/gn_isolate_map.pyl':
+            ("{'foo_unittests_script': {"
+             "  'label': '//foo:foo_unittests',"
+             "  'type': 'script',"
+             "  'script': '//foo/foo_unittests_script.py',"
+             "}}\n"),
+            '/fake_src/out/Default/foo_unittests_script.runtime_deps':
+            ("foo_unittests\n"
+             "foo_unittests_script.py\n"),
+        }
+        mbw = self.check([
+            'gen', '-c', 'debug_goma', '//out/Default',
+            '--swarming-targets-file', '/tmp/swarming_targets',
+            '--isolate-map-file',
+            '/fake_src/testing/buildbot/gn_isolate_map.pyl'
+        ],
+                         files=test_files,
+                         ret=0)
 
-    isolate_file = (
-        mbw.files['/fake_src/out/Default/foo_unittests_script.isolate'])
-    isolate_file_contents = ast.literal_eval(isolate_file)
-    files = isolate_file_contents['variables']['files']
-    command = isolate_file_contents['variables']['command']
+        isolate_file = (
+            mbw.files['/fake_src/out/Default/foo_unittests_script.isolate'])
+        isolate_file_contents = ast.literal_eval(isolate_file)
+        files = isolate_file_contents['variables']['files']
+        command = isolate_file_contents['variables']['command']
 
-    self.assertEqual(files, [
-        '../../.vpython3',
-        '../../testing/test_env.py',
-        'foo_unittests',
-        'foo_unittests_script.py',
-    ])
-    self.assertEqual(command, [
-        'vpython3',
-        '../../foo/foo_unittests_script.py',
-    ])
+        self.assertEqual(files, [
+            '../../.vpython3',
+            '../../testing/test_env.py',
+            'foo_unittests',
+            'foo_unittests_script.py',
+        ])
+        self.assertEqual(command, [
+            'vpython3',
+            '../../foo/foo_unittests_script.py',
+        ])
 
-  def test_gen_raw(self):
-    test_files = {
-        '/tmp/swarming_targets':
-        'foo_unittests\n',
-        '/fake_src/testing/buildbot/gn_isolate_map.pyl':
-        ("{'foo_unittests': {"
-         "  'label': '//foo:foo_unittests',"
-         "  'type': 'raw',"
-         "}}\n"),
-        '/fake_src/out/Default/foo_unittests.runtime_deps': ("foo_unittests\n"),
-    }
-    mbw = self.check([
-        'gen', '-c', 'debug_goma', '//out/Default', '--swarming-targets-file',
-        '/tmp/swarming_targets', '--isolate-map-file',
-        '/fake_src/testing/buildbot/gn_isolate_map.pyl'
-    ],
-                     files=test_files,
-                     ret=0)
+    def test_gen_raw(self):
+        test_files = {
+            '/tmp/swarming_targets':
+            'foo_unittests\n',
+            '/fake_src/testing/buildbot/gn_isolate_map.pyl':
+            ("{'foo_unittests': {"
+             "  'label': '//foo:foo_unittests',"
+             "  'type': 'raw',"
+             "}}\n"),
+            '/fake_src/out/Default/foo_unittests.runtime_deps':
+            ("foo_unittests\n"),
+        }
+        mbw = self.check([
+            'gen', '-c', 'debug_goma', '//out/Default',
+            '--swarming-targets-file', '/tmp/swarming_targets',
+            '--isolate-map-file',
+            '/fake_src/testing/buildbot/gn_isolate_map.pyl'
+        ],
+                         files=test_files,
+                         ret=0)
 
-    isolate_file = mbw.files['/fake_src/out/Default/foo_unittests.isolate']
-    isolate_file_contents = ast.literal_eval(isolate_file)
-    files = isolate_file_contents['variables']['files']
-    command = isolate_file_contents['variables']['command']
+        isolate_file = mbw.files['/fake_src/out/Default/foo_unittests.isolate']
+        isolate_file_contents = ast.literal_eval(isolate_file)
+        files = isolate_file_contents['variables']['files']
+        command = isolate_file_contents['variables']['command']
 
-    self.assertEqual(files, [
-        '../../.vpython3',
-        '../../testing/test_env.py',
-        'foo_unittests',
-    ])
-    self.assertEqual(command, ['bin/run_foo_unittests'])
+        self.assertEqual(files, [
+            '../../.vpython3',
+            '../../testing/test_env.py',
+            'foo_unittests',
+        ])
+        self.assertEqual(command, ['bin/run_foo_unittests'])
 
-  def test_gen_non_parallel_console_test_launcher(self):
-    test_files = {
-        '/tmp/swarming_targets':
-        'foo_unittests\n',
-        '/fake_src/testing/buildbot/gn_isolate_map.pyl':
-        ("{'foo_unittests': {"
-         "  'label': '//foo:foo_unittests',"
-         "  'type': 'non_parallel_console_test_launcher',"
-         "}}\n"),
-        '/fake_src/out/Default/foo_unittests.runtime_deps': ("foo_unittests\n"),
-    }
-    mbw = self.check([
-        'gen', '-c', 'debug_goma', '//out/Default', '--swarming-targets-file',
-        '/tmp/swarming_targets', '--isolate-map-file',
-        '/fake_src/testing/buildbot/gn_isolate_map.pyl'
-    ],
-                     files=test_files,
-                     ret=0)
+    def test_gen_non_parallel_console_test_launcher(self):
+        test_files = {
+            '/tmp/swarming_targets':
+            'foo_unittests\n',
+            '/fake_src/testing/buildbot/gn_isolate_map.pyl':
+            ("{'foo_unittests': {"
+             "  'label': '//foo:foo_unittests',"
+             "  'type': 'non_parallel_console_test_launcher',"
+             "}}\n"),
+            '/fake_src/out/Default/foo_unittests.runtime_deps':
+            ("foo_unittests\n"),
+        }
+        mbw = self.check([
+            'gen', '-c', 'debug_goma', '//out/Default',
+            '--swarming-targets-file', '/tmp/swarming_targets',
+            '--isolate-map-file',
+            '/fake_src/testing/buildbot/gn_isolate_map.pyl'
+        ],
+                         files=test_files,
+                         ret=0)
 
-    isolate_file = mbw.files['/fake_src/out/Default/foo_unittests.isolate']
-    isolate_file_contents = ast.literal_eval(isolate_file)
-    files = isolate_file_contents['variables']['files']
-    command = isolate_file_contents['variables']['command']
+        isolate_file = mbw.files['/fake_src/out/Default/foo_unittests.isolate']
+        isolate_file_contents = ast.literal_eval(isolate_file)
+        files = isolate_file_contents['variables']['files']
+        command = isolate_file_contents['variables']['command']
 
-    self.assertEqual(files, [
-        '../../.vpython3',
-        '../../testing/test_env.py',
-        '../../third_party/gtest-parallel/gtest-parallel',
-        '../../third_party/gtest-parallel/gtest_parallel.py',
-        '../../tools_webrtc/gtest-parallel-wrapper.py',
-        'foo_unittests',
-    ])
-    self.assertEqual(command, [
-        'vpython3',
-        '../../testing/test_env.py',
-        '../../tools_webrtc/gtest-parallel-wrapper.py',
-        '--output_dir=${ISOLATED_OUTDIR}/test_logs',
-        '--gtest_color=no',
-        '--workers=1',
-        '--retry_failed=3',
-        './foo_unittests',
-        '--asan=0',
-        '--lsan=0',
-        '--msan=0',
-        '--tsan=0',
-    ])
+        self.assertEqual(files, [
+            '../../.vpython3',
+            '../../testing/test_env.py',
+            '../../third_party/gtest-parallel/gtest-parallel',
+            '../../third_party/gtest-parallel/gtest_parallel.py',
+            '../../tools_webrtc/gtest-parallel-wrapper.py',
+            'foo_unittests',
+        ])
+        self.assertEqual(command, [
+            'vpython3',
+            '../../testing/test_env.py',
+            '../../tools_webrtc/gtest-parallel-wrapper.py',
+            '--output_dir=${ISOLATED_OUTDIR}/test_logs',
+            '--gtest_color=no',
+            '--workers=1',
+            '--retry_failed=3',
+            './foo_unittests',
+            '--asan=0',
+            '--lsan=0',
+            '--msan=0',
+            '--tsan=0',
+        ])
 
-  def test_isolate_windowed_test_launcher_linux(self):
-    test_files = {
-        '/tmp/swarming_targets':
-        'foo_unittests\n',
-        '/fake_src/testing/buildbot/gn_isolate_map.pyl':
-        ("{'foo_unittests': {"
-         "  'label': '//foo:foo_unittests',"
-         "  'type': 'windowed_test_launcher',"
-         "}}\n"),
-        '/fake_src/out/Default/foo_unittests.runtime_deps':
-        ("foo_unittests\n"
-         "some_resource_file\n"),
-    }
-    mbw = self.check([
-        'gen', '-c', 'debug_goma', '//out/Default', '--swarming-targets-file',
-        '/tmp/swarming_targets', '--isolate-map-file',
-        '/fake_src/testing/buildbot/gn_isolate_map.pyl'
-    ],
-                     files=test_files,
-                     ret=0)
+    def test_isolate_windowed_test_launcher_linux(self):
+        test_files = {
+            '/tmp/swarming_targets':
+            'foo_unittests\n',
+            '/fake_src/testing/buildbot/gn_isolate_map.pyl':
+            ("{'foo_unittests': {"
+             "  'label': '//foo:foo_unittests',"
+             "  'type': 'windowed_test_launcher',"
+             "}}\n"),
+            '/fake_src/out/Default/foo_unittests.runtime_deps':
+            ("foo_unittests\n"
+             "some_resource_file\n"),
+        }
+        mbw = self.check([
+            'gen', '-c', 'debug_goma', '//out/Default',
+            '--swarming-targets-file', '/tmp/swarming_targets',
+            '--isolate-map-file',
+            '/fake_src/testing/buildbot/gn_isolate_map.pyl'
+        ],
+                         files=test_files,
+                         ret=0)
 
-    isolate_file = mbw.files['/fake_src/out/Default/foo_unittests.isolate']
-    isolate_file_contents = ast.literal_eval(isolate_file)
-    files = isolate_file_contents['variables']['files']
-    command = isolate_file_contents['variables']['command']
+        isolate_file = mbw.files['/fake_src/out/Default/foo_unittests.isolate']
+        isolate_file_contents = ast.literal_eval(isolate_file)
+        files = isolate_file_contents['variables']['files']
+        command = isolate_file_contents['variables']['command']
 
-    self.assertEqual(files, [
-        '../../.vpython3',
-        '../../testing/test_env.py',
-        '../../testing/xvfb.py',
-        '../../third_party/gtest-parallel/gtest-parallel',
-        '../../third_party/gtest-parallel/gtest_parallel.py',
-        '../../tools_webrtc/gtest-parallel-wrapper.py',
-        'foo_unittests',
-        'some_resource_file',
-    ])
-    self.assertEqual(command, [
-        'vpython3',
-        '../../testing/xvfb.py',
-        '../../tools_webrtc/gtest-parallel-wrapper.py',
-        '--output_dir=${ISOLATED_OUTDIR}/test_logs',
-        '--gtest_color=no',
-        '--retry_failed=3',
-        './foo_unittests',
-        '--asan=0',
-        '--lsan=0',
-        '--msan=0',
-        '--tsan=0',
-    ])
+        self.assertEqual(files, [
+            '../../.vpython3',
+            '../../testing/test_env.py',
+            '../../testing/xvfb.py',
+            '../../third_party/gtest-parallel/gtest-parallel',
+            '../../third_party/gtest-parallel/gtest_parallel.py',
+            '../../tools_webrtc/gtest-parallel-wrapper.py',
+            'foo_unittests',
+            'some_resource_file',
+        ])
+        self.assertEqual(command, [
+            'vpython3',
+            '../../testing/xvfb.py',
+            '../../tools_webrtc/gtest-parallel-wrapper.py',
+            '--output_dir=${ISOLATED_OUTDIR}/test_logs',
+            '--gtest_color=no',
+            '--retry_failed=3',
+            './foo_unittests',
+            '--asan=0',
+            '--lsan=0',
+            '--msan=0',
+            '--tsan=0',
+        ])
 
-  def test_gen_windowed_test_launcher_win(self):
-    files = {
-        'c:\\fake_src\\out\\Default\\tmp\\swarming_targets':
-        'unittests\n',
-        'c:\\fake_src\\testing\\buildbot\\gn_isolate_map.pyl':
-        ("{'unittests': {"
-         "  'label': '//somewhere:unittests',"
-         "  'type': 'windowed_test_launcher',"
-         "}}\n"),
-        r'c:\fake_src\out\Default\unittests.exe.runtime_deps':
-        ("unittests.exe\n"
-         "some_dependency\n"),
-    }
-    mbw = CreateFakeMBW(files=files, win32=True)
-    self.check([
-        'gen', '-c', 'debug_goma', '--swarming-targets-file',
-        'c:\\fake_src\\out\\Default\\tmp\\swarming_targets',
-        '--isolate-map-file',
-        'c:\\fake_src\\testing\\buildbot\\gn_isolate_map.pyl', '//out/Default'
-    ],
-               mbw=mbw,
-               ret=0)
+    def test_gen_windowed_test_launcher_win(self):
+        files = {
+            'c:\\fake_src\\out\\Default\\tmp\\swarming_targets':
+            'unittests\n',
+            'c:\\fake_src\\testing\\buildbot\\gn_isolate_map.pyl':
+            ("{'unittests': {"
+             "  'label': '//somewhere:unittests',"
+             "  'type': 'windowed_test_launcher',"
+             "}}\n"),
+            r'c:\fake_src\out\Default\unittests.exe.runtime_deps':
+            ("unittests.exe\n"
+             "some_dependency\n"),
+        }
+        mbw = CreateFakeMBW(files=files, win32=True)
+        self.check([
+            'gen', '-c', 'debug_goma', '--swarming-targets-file',
+            'c:\\fake_src\\out\\Default\\tmp\\swarming_targets',
+            '--isolate-map-file',
+            'c:\\fake_src\\testing\\buildbot\\gn_isolate_map.pyl',
+            '//out/Default'
+        ],
+                   mbw=mbw,
+                   ret=0)
 
-    isolate_file = mbw.files['c:\\fake_src\\out\\Default\\unittests.isolate']
-    isolate_file_contents = ast.literal_eval(isolate_file)
-    files = isolate_file_contents['variables']['files']
-    command = isolate_file_contents['variables']['command']
+        isolate_file = mbw.files[
+            'c:\\fake_src\\out\\Default\\unittests.isolate']
+        isolate_file_contents = ast.literal_eval(isolate_file)
+        files = isolate_file_contents['variables']['files']
+        command = isolate_file_contents['variables']['command']
 
-    self.assertEqual(files, [
-        '../../.vpython3',
-        '../../testing/test_env.py',
-        '../../third_party/gtest-parallel/gtest-parallel',
-        '../../third_party/gtest-parallel/gtest_parallel.py',
-        '../../tools_webrtc/gtest-parallel-wrapper.py',
-        'some_dependency',
-        'unittests.exe',
-    ])
-    self.assertEqual(command, [
-        'vpython3',
-        '../../testing/test_env.py',
-        '../../tools_webrtc/gtest-parallel-wrapper.py',
-        '--output_dir=${ISOLATED_OUTDIR}/test_logs',
-        '--gtest_color=no',
-        '--retry_failed=3',
-        r'.\unittests.exe',
-        '--asan=0',
-        '--lsan=0',
-        '--msan=0',
-        '--tsan=0',
-    ])
+        self.assertEqual(files, [
+            '../../.vpython3',
+            '../../testing/test_env.py',
+            '../../third_party/gtest-parallel/gtest-parallel',
+            '../../third_party/gtest-parallel/gtest_parallel.py',
+            '../../tools_webrtc/gtest-parallel-wrapper.py',
+            'some_dependency',
+            'unittests.exe',
+        ])
+        self.assertEqual(command, [
+            'vpython3',
+            '../../testing/test_env.py',
+            '../../tools_webrtc/gtest-parallel-wrapper.py',
+            '--output_dir=${ISOLATED_OUTDIR}/test_logs',
+            '--gtest_color=no',
+            '--retry_failed=3',
+            r'.\unittests.exe',
+            '--asan=0',
+            '--lsan=0',
+            '--msan=0',
+            '--tsan=0',
+        ])
 
-  def test_gen_console_test_launcher(self):
-    test_files = {
-        '/tmp/swarming_targets':
-        'foo_unittests\n',
-        '/fake_src/testing/buildbot/gn_isolate_map.pyl':
-        ("{'foo_unittests': {"
-         "  'label': '//foo:foo_unittests',"
-         "  'type': 'console_test_launcher',"
-         "}}\n"),
-        '/fake_src/out/Default/foo_unittests.runtime_deps': ("foo_unittests\n"),
-    }
-    mbw = self.check([
-        'gen', '-c', 'debug_goma', '//out/Default', '--swarming-targets-file',
-        '/tmp/swarming_targets', '--isolate-map-file',
-        '/fake_src/testing/buildbot/gn_isolate_map.pyl'
-    ],
-                     files=test_files,
-                     ret=0)
+    def test_gen_console_test_launcher(self):
+        test_files = {
+            '/tmp/swarming_targets':
+            'foo_unittests\n',
+            '/fake_src/testing/buildbot/gn_isolate_map.pyl':
+            ("{'foo_unittests': {"
+             "  'label': '//foo:foo_unittests',"
+             "  'type': 'console_test_launcher',"
+             "}}\n"),
+            '/fake_src/out/Default/foo_unittests.runtime_deps':
+            ("foo_unittests\n"),
+        }
+        mbw = self.check([
+            'gen', '-c', 'debug_goma', '//out/Default',
+            '--swarming-targets-file', '/tmp/swarming_targets',
+            '--isolate-map-file',
+            '/fake_src/testing/buildbot/gn_isolate_map.pyl'
+        ],
+                         files=test_files,
+                         ret=0)
 
-    isolate_file = mbw.files['/fake_src/out/Default/foo_unittests.isolate']
-    isolate_file_contents = ast.literal_eval(isolate_file)
-    files = isolate_file_contents['variables']['files']
-    command = isolate_file_contents['variables']['command']
+        isolate_file = mbw.files['/fake_src/out/Default/foo_unittests.isolate']
+        isolate_file_contents = ast.literal_eval(isolate_file)
+        files = isolate_file_contents['variables']['files']
+        command = isolate_file_contents['variables']['command']
 
-    self.assertEqual(files, [
-        '../../.vpython3',
-        '../../testing/test_env.py',
-        '../../third_party/gtest-parallel/gtest-parallel',
-        '../../third_party/gtest-parallel/gtest_parallel.py',
-        '../../tools_webrtc/gtest-parallel-wrapper.py',
-        'foo_unittests',
-    ])
-    self.assertEqual(command, [
-        'vpython3',
-        '../../testing/test_env.py',
-        '../../tools_webrtc/gtest-parallel-wrapper.py',
-        '--output_dir=${ISOLATED_OUTDIR}/test_logs',
-        '--gtest_color=no',
-        '--retry_failed=3',
-        './foo_unittests',
-        '--asan=0',
-        '--lsan=0',
-        '--msan=0',
-        '--tsan=0',
-    ])
+        self.assertEqual(files, [
+            '../../.vpython3',
+            '../../testing/test_env.py',
+            '../../third_party/gtest-parallel/gtest-parallel',
+            '../../third_party/gtest-parallel/gtest_parallel.py',
+            '../../tools_webrtc/gtest-parallel-wrapper.py',
+            'foo_unittests',
+        ])
+        self.assertEqual(command, [
+            'vpython3',
+            '../../testing/test_env.py',
+            '../../tools_webrtc/gtest-parallel-wrapper.py',
+            '--output_dir=${ISOLATED_OUTDIR}/test_logs',
+            '--gtest_color=no',
+            '--retry_failed=3',
+            './foo_unittests',
+            '--asan=0',
+            '--lsan=0',
+            '--msan=0',
+            '--tsan=0',
+        ])
 
-  def test_isolate_test_launcher_with_webcam(self):
-    test_files = {
-        '/tmp/swarming_targets':
-        'foo_unittests\n',
-        '/fake_src/testing/buildbot/gn_isolate_map.pyl':
-        ("{'foo_unittests': {"
-         "  'label': '//foo:foo_unittests',"
-         "  'type': 'console_test_launcher',"
-         "  'use_webcam': True,"
-         "}}\n"),
-        '/fake_src/out/Default/foo_unittests.runtime_deps':
-        ("foo_unittests\n"
-         "some_resource_file\n"),
-    }
-    mbw = self.check([
-        'gen', '-c', 'debug_goma', '//out/Default', '--swarming-targets-file',
-        '/tmp/swarming_targets', '--isolate-map-file',
-        '/fake_src/testing/buildbot/gn_isolate_map.pyl'
-    ],
-                     files=test_files,
-                     ret=0)
+    def test_isolate(self):
+        files = {
+            '/fake_src/out/Default/toolchain.ninja':
+            "",
+            '/fake_src/testing/buildbot/gn_isolate_map.pyl':
+            ("{'foo_unittests': {"
+             "  'label': '//foo:foo_unittests',"
+             "  'type': 'non_parallel_console_test_launcher',"
+             "}}\n"),
+            '/fake_src/out/Default/foo_unittests.runtime_deps':
+            ("foo_unittests\n"),
+        }
+        self.check(
+            ['isolate', '-c', 'debug_goma', '//out/Default', 'foo_unittests'],
+            files=files,
+            ret=0)
 
-    isolate_file = mbw.files['/fake_src/out/Default/foo_unittests.isolate']
-    isolate_file_contents = ast.literal_eval(isolate_file)
-    files = isolate_file_contents['variables']['files']
-    command = isolate_file_contents['variables']['command']
-
-    self.assertEqual(files, [
-        '../../.vpython3',
-        '../../testing/test_env.py',
-        '../../third_party/gtest-parallel/gtest-parallel',
-        '../../third_party/gtest-parallel/gtest_parallel.py',
-        '../../tools_webrtc/ensure_webcam_is_running.py',
-        '../../tools_webrtc/gtest-parallel-wrapper.py',
-        'foo_unittests',
-        'some_resource_file',
-    ])
-    self.assertEqual(command, [
-        'vpython3',
-        '../../tools_webrtc/ensure_webcam_is_running.py',
-        'vpython3',
-        '../../testing/test_env.py',
-        '../../tools_webrtc/gtest-parallel-wrapper.py',
-        '--output_dir=${ISOLATED_OUTDIR}/test_logs',
-        '--gtest_color=no',
-        '--retry_failed=3',
-        './foo_unittests',
-        '--asan=0',
-        '--lsan=0',
-        '--msan=0',
-        '--tsan=0',
-    ])
-
-  def test_isolate(self):
-    files = {
-        '/fake_src/out/Default/toolchain.ninja':
-        "",
-        '/fake_src/testing/buildbot/gn_isolate_map.pyl':
-        ("{'foo_unittests': {"
-         "  'label': '//foo:foo_unittests',"
-         "  'type': 'non_parallel_console_test_launcher',"
-         "}}\n"),
-        '/fake_src/out/Default/foo_unittests.runtime_deps': ("foo_unittests\n"),
-    }
-    self.check(
-        ['isolate', '-c', 'debug_goma', '//out/Default', 'foo_unittests'],
-        files=files,
-        ret=0)
-
-    # test running isolate on an existing build_dir
-    files['/fake_src/out/Default/args.gn'] = 'is_debug = true\n'
-    self.check(['isolate', '//out/Default', 'foo_unittests'],
-               files=files,
-               ret=0)
-    files['/fake_src/out/Default/mb_type'] = 'gn\n'
-    self.check(['isolate', '//out/Default', 'foo_unittests'],
-               files=files,
-               ret=0)
+        # test running isolate on an existing build_dir
+        files['/fake_src/out/Default/args.gn'] = 'is_debug = true\n'
+        self.check(['isolate', '//out/Default', 'foo_unittests'],
+                   files=files,
+                   ret=0)
+        files['/fake_src/out/Default/mb_type'] = 'gn\n'
+        self.check(['isolate', '//out/Default', 'foo_unittests'],
+                   files=files,
+                   ret=0)
 
 if __name__ == '__main__':
-  unittest.main()
+    unittest.main()