Improve presubmit for histogram name typos

Currently, _CheckUmaHistogramChanges detects the cases like calling
  UMA_HISTOGRAM_BOOLEAN("NonexistingHistogram.Typo", true)
when "NonexistingHistogram.Typo" is not a histogram name defined in
histograms.xml.

However, it won't detect the case when the name is after a line break:
  UMA_HISTOGRAM_BOOLEAN(
      "NonexistingHistogram.VeeeeeeeryLoooooooongName.WithSubitems",
      true)

This will be often the case once the check gets extended to Java,
where the UMA_HISTOGRAM* macros are replaced with the
RecordHistogram.record*Histogram methods, which have longer names.

Bug: 821981
Cq-Include-Trybots: master.tryserver.chromium.mac:ios-simulator-cronet;master.tryserver.chromium.mac:ios-simulator-full-configs
Change-Id: I71d01f3b7012e8a8d6c4628d67a470c57005cd56
Reviewed-on: https://chromium-review.googlesource.com/978219
Commit-Queue: Vaclav Brozek <[email protected]>
Reviewed-by: Daniel Cheng <[email protected]>
Cr-Commit-Position: refs/heads/master@{#545676}
diff --git a/PRESUBMIT_test.py b/PRESUBMIT_test.py
index 4532042..363e8d49 100755
--- a/PRESUBMIT_test.py
+++ b/PRESUBMIT_test.py
@@ -130,6 +130,21 @@
                                                    MockOutputApi())
     self.assertEqual(0, len(warnings))
 
+  def testMultiLine(self):
+    diff_cc = ['UMA_HISTOGRAM_BOOLEAN(', '    "Multi.Line", true)']
+    diff_cc2 = ['UMA_HISTOGRAM_BOOLEAN(', '    "Multi.Line"', '    , true)']
+    mock_input_api = MockInputApi()
+    mock_input_api.files = [
+      MockFile('some/path/foo.cc', diff_cc),
+      MockFile('some/path/foo2.cc', diff_cc2),
+    ]
+    warnings = PRESUBMIT._CheckUmaHistogramChanges(mock_input_api,
+                                                   MockOutputApi())
+    self.assertEqual(1, len(warnings))
+    self.assertEqual('warning', warnings[0].type)
+    self.assertTrue('foo.cc' in warnings[0].items[0])
+    self.assertTrue('foo2.cc' in warnings[0].items[1])
+
 class BadExtensionsTest(unittest.TestCase):
   def testBadRejFile(self):
     mock_input_api = MockInputApi()