Do not run CheckNoStreamUsageIsAdded on tests.

No-Try: True
Bug: None
Change-Id: I8370b28b3a936e96cfd5382de4508c3809c61d93
Reviewed-on: https://webrtc-review.googlesource.com/c/src/+/135462
Reviewed-by: Karl Wiberg <kwiberg@webrtc.org>
Reviewed-by: Niels Moller <nisse@webrtc.org>
Commit-Queue: Mirko Bonadei <mbonadei@webrtc.org>
Cr-Commit-Position: refs/heads/master@{#27867}
diff --git a/PRESUBMIT.py b/PRESUBMIT.py
index 4dd6a32..dbbdb6a 100755
--- a/PRESUBMIT.py
+++ b/PRESUBMIT.py
@@ -498,9 +498,16 @@
       r'// no-presubmit-check TODO\(webrtc:8982\)')
   file_filter = lambda x: (input_api.FilterSourceFile(x)
                            and source_file_filter(x))
+
+  def _IsException(file_path):
+    is_test = any(file_path.endswith(x) for x in ['_test.cc', '_tests.cc',
+                                                  '_unittest.cc',
+                                                  '_unittests.cc'])
+    return file_path.startswith('examples') or is_test
+
   for f in input_api.AffectedSourceFiles(file_filter):
-    # Usage of stringstream is allowed under examples/.
-    if f.LocalPath() == 'PRESUBMIT.py' or f.LocalPath().startswith('examples'):
+    # Usage of stringstream is allowed under examples/ and in tests.
+    if f.LocalPath() == 'PRESUBMIT.py' or _IsException(f.LocalPath()):
       continue
     for line_num, line in f.ChangedContents():
       if ((include_re.search(line) or usage_re.search(line))