Require translation screenshot if none exists or message content changed

* The current translation screenshot presubmit check flags messages
  which got modified but for which no new translation screenshot
  got uploaded. It thereby also flags messages that got modified, but of
  which the message content itself did not change. This is the case, for
  example, if only the message description for translators got changed.
* This CL restricts the translation screenshot presubmit flagging
  modified messages. It will trigger 1) if the message did not have a
  screenshot at all so far, or 2) if the message content itself changed.
  Only changing the non-visible part of a message that already has a
  translation screenshot does not trigger it anymore.

Bug: 1103844
Change-Id: I254ce2a7267a7d2308b606b16d080c74188d582b
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2328669
Commit-Queue: Rainhard Findling <rainhard@chromium.org>
Reviewed-by: Jochen Eisinger <jochen@chromium.org>
Reviewed-by: Mustafa Emre Acer <meacer@chromium.org>
Cr-Commit-Position: refs/heads/master@{#797648}
diff --git a/PRESUBMIT_test.py b/PRESUBMIT_test.py
index cb9461d..c6f01c89f 100755
--- a/PRESUBMIT_test.py
+++ b/PRESUBMIT_test.py
@@ -2872,6 +2872,22 @@
       '</message>',
     '</grit-part>')
 
+  NEW_GRDP_CONTENTS3 = (
+    '<?xml version="1.0" encoding="utf-8"?>',
+      '<grit-part>',
+        '<message name="IDS_PART_TEST1" desc="Description with typo.">',
+          'Part string 1',
+        '</message>',
+    '</grit-part>')
+
+  NEW_GRDP_CONTENTS4 = (
+    '<?xml version="1.0" encoding="utf-8"?>',
+      '<grit-part>',
+        '<message name="IDS_PART_TEST1" desc="Description with typo fixed.">',
+          'Part string 1',
+        '</message>',
+    '</grit-part>')
+
   # A grdp file with one ICU syntax message without syntax errors.
   NEW_GRDP_CONTENTS_ICU_SYNTAX_OK1 = (
     '<?xml version="1.0" encoding="utf-8"?>',
@@ -2975,6 +2991,25 @@
         os.path.join('test_grd', 'IDS_TEST2.png.sha1'),
     ], warnings[0].items)
 
+  def testModifiedMessageDescription(self):
+    # CL modified a message description for a message that does not yet have a
+    # screenshot. Should warn.
+    input_api = self.makeInputApi([
+      MockAffectedFile('part.grdp', self.NEW_GRDP_CONTENTS3,
+                       self.NEW_GRDP_CONTENTS4, action='M')])
+    warnings = PRESUBMIT.CheckStrings(input_api, MockOutputApi())
+    self.assertEqual(1, len(warnings))
+
+    # CL modified a message description for a message that already has a
+    # screenshot. Should not warn.
+    input_api = self.makeInputApi([
+      MockAffectedFile('part.grdp', self.NEW_GRDP_CONTENTS3,
+                       self.NEW_GRDP_CONTENTS4, action='M'),
+      MockFile(os.path.join('part_grdp', 'IDS_PART_TEST1.png.sha1'),
+               'binary', action='A')])
+    warnings = PRESUBMIT.CheckStrings(input_api, MockOutputApi())
+    self.assertEqual(0, len(warnings))
+
   def testPngAddedSha1NotAdded(self):
     # CL added one new message in a grd file and added the png file associated
     # with it, but did not add the corresponding sha1 file. This should warn