firmware_TouchMTB: Use graphics_utils for getting screen resolution.

Improves Freonization, although screenshots still aren't ported.

Version 2: Whitespace fixes pointed out by Ilja.

BUG=chromium:413078
TEST=Run the test and make sure it's still green.

Signed-off-by: Corbin Simpson <simpsoco@chromium.org>
Change-Id: I6f3a8e69ec386f1e140e00f04362cfad409ac544
Reviewed-on: https://chromium-review.googlesource.com/230281
Reviewed-by: Ilja Friedel <ihf@chromium.org>
Reviewed-by: Shyh-In Hwang <josephsih@chromium.org>
Tested-by: Ilja Friedel <ihf@chromium.org>
diff --git a/client/site_tests/firmware_TouchMTB/firmware_utils.py b/client/site_tests/firmware_TouchMTB/firmware_utils.py
index c2c8a4d..ea3e93a 100644
--- a/client/site_tests/firmware_TouchMTB/firmware_utils.py
+++ b/client/site_tests/firmware_TouchMTB/firmware_utils.py
@@ -19,22 +19,6 @@
     return ':0'
 
 
-def get_screen_size():
-    """Get the screen size using xwininfo."""
-    cmd = 'DISPLAY=:0 xwininfo -root'
-    wininfo = common_util.simple_system_output(cmd)
-    # the geometry string looks like:
-    #     "  -geometry 3840x1200+0+0"
-    geometry_pattern = re.compile('\s*-geometry\s*(\d+)x(\d+)+.*', re.I)
-    for line in wininfo.splitlines():
-        result = geometry_pattern.search(line)
-        if result:
-            width = int(result.group(1))
-            height = int(result.group(2))
-            return (width, height)
-    return None
-
-
 def get_current_time_str():
     """Get the string of current time."""
     time_format = '%Y%m%d_%H%M%S'
@@ -151,7 +135,12 @@
 
 
 def create_log_dir(firmware_version, mode):
-    """Create a directory to save the report and device event files."""
+    """
+    Create a directory to save the report and device event files.
+
+    @param firmware_version: The firmware version.
+    @param mode: The mode with which to create the directory.
+    """
     dir_basename = conf.filename.sep.join([get_current_time_str(),
                                            conf.fw_prefix + firmware_version,
                                            mode])
@@ -243,18 +232,33 @@
         return self.prefix_space
 
     def print_report_line(self, msg):
-        """Print the line with proper indentation."""
+        """
+        Print the line with proper indentation.
+
+        @param msg: The line to print.
+        """
+
         self.report.write(self.prefix_space + str(msg) + os.linesep)
 
     def print_window(self, msg):
-        """Print the message to the result window."""
+        """
+        Print the message to the result window.
+
+        @param msg: The line to print.
+        """
+
         if type(msg) is list:
             msg = os.linesep.join(msg)
         self.win.set_result(msg)
         print msg
 
     def _print_report(self, msg):
-        """Print the message to the report."""
+        """
+        Print the message to the report.
+
+        @param msg: The line to print.
+        """
+
         if type(msg) is list:
             for line in msg:
                 self.print_report_line(line)
@@ -267,7 +271,10 @@
         Usage of the method: the validator test result of a gesture may
         be discarded because the user chooses to re-perform the gesture
         again. So it should be able to over-write the message.
+
+        @param msg: The line to print.
         """
+
         self.msg = msg
 
     def flush_report(self):
@@ -277,18 +284,29 @@
             self.msg = None
 
     def print_report(self, msg):
-        """Print the message to the report."""
+        """
+        Print the message to the report.
+
+        @param msg: The line to print.
+        """
+
         # Print any buffered message first.
         self.flush_report()
         # Print this incoming message
         self._print_report(msg)
 
     def print_all(self, msg):
-        """Print the message to both report and to the window."""
+        """
+        Print the message to both report and to the window.
+
+        @param msg: The line to print.
+        """
+
         self.print_window(msg)
         self.buffer_report(msg)
 
 
+#TODO: This class is not Freon-ready!
 class ScreenShot:
     """Handle screen shot."""
 
@@ -303,7 +321,12 @@
         self.get_id_cmd = 'DISPLAY=:0 xwininfo -root -tree'
 
     def dump_window(self, filename):
-        """Dump the screenshot of a window to the specified file name."""
+        """
+        Dump the screenshot of a window to the specified file name.
+
+        @param filename: The filename to save the screenshot as.
+        """
+
         win_id = self._get_win_id()
         if win_id:
             dump_cmd = self.dump_window_format % (win_id, filename)
@@ -312,7 +335,12 @@
             print 'Warning: cannot get the window id.'
 
     def dump_root(self, filename):
-        """Dump the screenshot of root to the specified file name."""
+        """
+        Dump the screenshot of root to the specified file name.
+
+        @param filename: The filename to save the screenshot as.
+        """
+
         dump_cmd = self.dump_root_format % (self.geometry_str, filename)
         common_util.simple_system(dump_cmd)
 
diff --git a/client/site_tests/firmware_TouchMTB/main.py b/client/site_tests/firmware_TouchMTB/main.py
index 2092422..10a91de 100755
--- a/client/site_tests/firmware_TouchMTB/main.py
+++ b/client/site_tests/firmware_TouchMTB/main.py
@@ -11,6 +11,8 @@
 import os
 import sys
 
+from client.cros.graphics import graphics_utils
+
 import common
 import cros_gs
 import firmware_utils
@@ -255,7 +257,7 @@
 
     def _get_screen_size(self):
         """Get the screen size."""
-        self.screen_size = firmware_utils.get_screen_size()
+        self.screen_size = graphics_utils.get_screen_resolution()
 
     def _get_touch_device_window_geometry(self):
         """Get the preferred window geometry to display mtplot."""