Ensure autorelease pool is drained between tests

The testing::Test fixture (used by TEST macro) does not drain the
autorelease pool after a test. PlatformTest should be used.

Add a PRESUBMIT check that neither TEST nor testing::Test is used
in iOS Objective-C++ test files. Files are assumed to be iOS if
either their base name match '\bios\b' or one of the component in
the path is 'ios'.

Expand MockInputApi to filter files in mocks of AffectedFiles and
AffectedSourceFiles function, adding missing mocked functions too.
Fix unit tests that were failing after the filtering is correctly
implemented.

Bug: none
Change-Id: I0af99b6658b8e15888dfcfb94345eb879ab9fd37
Cq-Include-Trybots: master.tryserver.chromium.mac:ios-simulator-cronet;master.tryserver.chromium.mac:ios-simulator-full-configs
Reviewed-on: https://chromium-review.googlesource.com/937204
Reviewed-by: Jochen Eisinger <[email protected]>
Reviewed-by: Rohit Rao <[email protected]>
Commit-Queue: Sylvain Defresne <[email protected]>
Cr-Commit-Position: refs/heads/master@{#539829}
diff --git a/PRESUBMIT_test_mocks.py b/PRESUBMIT_test_mocks.py
index e15afcc..732da0e 100644
--- a/PRESUBMIT_test_mocks.py
+++ b/PRESUBMIT_test_mocks.py
@@ -58,6 +58,8 @@
   attribute as the list of changed files.
   """
 
+  DEFAULT_BLACK_LIST = ()
+
   def __init__(self):
     self.canned_checks = MockCannedChecks()
     self.fnmatch = fnmatch
@@ -74,10 +76,29 @@
     self.presubmit_local_path = os.path.dirname(__file__)
 
   def AffectedFiles(self, file_filter=None, include_deletes=False):
-    return self.files
+    for file in self.files:
+      if file_filter and not file_filter(file):
+        continue
+      if not include_deletes and file.Action() == 'D':
+        continue
+      yield file
 
   def AffectedSourceFiles(self, file_filter=None):
-    return self.files
+    return self.AffectedFiles(file_filter=file_filter)
+
+  def FilterSourceFile(self, file, white_list=(), black_list=()):
+    local_path = file.LocalPath()
+    if white_list:
+      for pattern in white_list:
+        compiled_pattern = re.compile(pattern)
+        if compiled_pattern.search(local_path):
+          return True
+    if black_list:
+      for pattern in black_list:
+        compiled_pattern = re.compile(pattern)
+        if compiled_pattern.search(local_path):
+          return False
+    return True
 
   def LocalPaths(self):
     return self.files