Chameleon: Generate the calibration image on client side
This is a part of CLs that moves logic from server to client.
This way helps code-reusability for client tests.
BUG=chromium:405143
TEST=Ran display_Resolution.mirrored passed on Falco
Change-Id: Ief1dde5785788212f35cece7cdefa90fb771c8fa
Reviewed-on: https://chromium-review.googlesource.com/226107
Tested-by: Wai-Hong Tam <waihong@chromium.org>
Reviewed-by: Hung-ying Tyan <tyanh@chromium.org>
Commit-Queue: Wai-Hong Tam <waihong@chromium.org>
diff --git a/server/cros/chameleon/calibration_images/template-1680x1052.svg b/client/cros/multimedia/calibration_images/template-1680x1052.svg
similarity index 100%
rename from server/cros/chameleon/calibration_images/template-1680x1052.svg
rename to client/cros/multimedia/calibration_images/template-1680x1052.svg
diff --git a/client/cros/multimedia/display_utility.py b/client/cros/multimedia/display_utility.py
index 6d4913c..e26ff43 100644
--- a/client/cros/multimedia/display_utility.py
+++ b/client/cros/multimedia/display_utility.py
@@ -13,6 +13,7 @@
from autotest_lib.client.bin import utils
from autotest_lib.client.cros import constants, sys_power
from autotest_lib.client.cros.graphics import graphics_utils
+from autotest_lib.client.cros.multimedia import image_generator
TimeoutException = telemetry.core.util.TimeoutException
@@ -20,9 +21,12 @@
class DisplayUtility(object):
"""Utility to access the display-related functionality."""
+ CALIBRATION_IMAGE_PATH = '/tmp/calibration.svg'
+
def __init__(self, chrome):
self._chrome = chrome
self._browser = chrome.browser
+ self._image_generator = image_generator.ImageGenerator()
def get_display_info(self):
@@ -315,7 +319,7 @@
return graphics_utils.wait_output_connected(output)
- def load_url(self, url):
+ def _load_url(self, url):
"""Loads the given url in a new tab.
@param url: The url to load as a string.
@@ -326,6 +330,18 @@
return True
+ def load_calibration_image(self, resolution):
+ """Load a full screen calibration image from the HTTP server.
+
+ @param resolution: A tuple (width, height) of resolution.
+ """
+ path = self.CALIBRATION_IMAGE_PATH
+ self._image_generator.generate_image(resolution[0], resolution[1], path)
+ os.chmod(path, 0644)
+ self._load_url('file://%s' % path)
+ return True
+
+
def close_tab(self, index=-1):
"""Closes the tab of the given index.
diff --git a/server/cros/chameleon/image_generator.py b/client/cros/multimedia/image_generator.py
similarity index 95%
rename from server/cros/chameleon/image_generator.py
rename to client/cros/multimedia/image_generator.py
index 9fda131..603be0e 100644
--- a/server/cros/chameleon/image_generator.py
+++ b/client/cros/multimedia/image_generator.py
@@ -1,4 +1,4 @@
-# Copyright (c) 2014 The Chromium OS Authors. All rights reserved.
+# Copyright 2014 The Chromium OS Authors. All rights reserved.
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.
diff --git a/server/cros/chameleon/display_client.py b/server/cros/chameleon/display_client.py
index 5b327b2..f2180eb 100644
--- a/server/cros/chameleon/display_client.py
+++ b/server/cros/chameleon/display_client.py
@@ -8,7 +8,6 @@
from PIL import Image
from autotest_lib.client.cros.multimedia.display_helper import DisplayInfo
-from autotest_lib.server.cros.chameleon import image_generator
class DisplayClient(object):
@@ -18,11 +17,6 @@
class on initialization, can be accessed from its _client property.
"""
-
- DEST_TMP_DIR = '/tmp'
- DEST_IMAGE_FILENAME = 'calibration.svg'
-
-
def __init__(self, host, multimedia_client_connection):
"""Construct a DisplayClient.
@@ -31,7 +25,6 @@
"""
self._client = host
self._connection = multimedia_client_connection
- self._image_generator = image_generator.ImageGenerator()
@property
@@ -72,17 +65,7 @@
@param resolution: A tuple (width, height) of resolution.
"""
- with tempfile.NamedTemporaryFile() as f:
- self._image_generator.generate_image(
- resolution[0], resolution[1], f.name)
- os.chmod(f.name, 0644)
- self._client.send_file(
- f.name,
- os.path.join(self.DEST_TMP_DIR, self.DEST_IMAGE_FILENAME))
-
- page_url = 'file://%s/%s' % (self.DEST_TMP_DIR,
- self.DEST_IMAGE_FILENAME)
- self._display_proxy.load_url(page_url)
+ self._display_proxy.load_calibration_image(resolution)
def close_tab(self, index=-1):