Add verification to ui_SystemTray tests.

Initially, we had the 'test' only collect screenshots of the
system tray with the intent to watch how the tray varies and
assess the general viability of image comparison based tests
in this area.

After watching the screenshots for a number of builds, it makes
sense to start with just the language indicator portion of the
tray.

This change collects this particular portion of the system tray,
pulls down a golden version of it and runs the comparison.

Comparisons are done locally first with a simple pixel by pixel
array walk. Failures are uploaded to bp for later viewing.

BUG=chromium:374981
TEST=Ran tests against a local link.
TEST=Ran video glitch detection tests also.

Change-Id: Ic5316d4d17a125b878c3c22b86568c554cf41186
Reviewed-on: https://chromium-review.googlesource.com/214380
Reviewed-by: Tracy Turchetto <tturchetto@chromium.org>
Tested-by: Mussa Kiroga <mussa@chromium.org>
Commit-Queue: Mussa Kiroga <mussa@chromium.org>
diff --git a/client/common_lib/site_utils.py b/client/common_lib/site_utils.py
index 8f44a9e..e2a89bf 100644
--- a/client/common_lib/site_utils.py
+++ b/client/common_lib/site_utils.py
@@ -375,6 +375,29 @@
     return fullpath
 
 
+def take_screenshot_crop(fullpath, box=None):
+    """
+    Take a screenshot using import tool, crop according to dim given by the box.
+
+    @param fullpath: path, full path to save the image to.
+    @param box: 4-tuple giving the upper left and lower right pixel coordinates.
+
+    """
+
+    if box:
+        upperx, uppery, lowerx, lowery = box
+
+        img_w = lowerx - upperx
+        img_h = lowery - uppery
+
+        import_cmd = ('/usr/local/bin/import -window root -depth 8 -crop '
+                      '%dx%d+%d+%d' % (img_w, img_h, upperx, uppery))
+    else:
+        import_cmd = ('/usr/local/bin/import -window root -depth 8')
+
+    _execute_screenshot_capture_command('%s %s' % (import_cmd, fullpath))
+
+
 def get_dut_display_resolution():
     """
     Parses output of xrandr to determine the display resolution of the dut.