Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(448)

Side by Side Diff: chrome/test/functional/ispy/common/ispy_utils.py

Issue 58623002: [I-Spy] Add utilities to help manage expectations that track Chrome versions. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: nit: slight changes to a docstring Created 7 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 # Copyright 2013 The Chromium Authors. All rights reserved. 1 # Copyright 2013 The Chromium Authors. All rights reserved.
2 # Use of this source code is governed by a BSD-style license that can be 2 # Use of this source code is governed by a BSD-style license that can be
3 # found in the LICENSE file. 3 # found in the LICENSE file.
4 4
5 """Utilities for managing I-Spy test results in Google Cloud Storage.""" 5 """Utilities for managing I-Spy test results in Google Cloud Storage."""
6 6
7 import collections 7 import collections
8 import itertools 8 import itertools
9 import json 9 import json
10 import os 10 import os
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
79 def UpdateImage(self, full_path, image): 79 def UpdateImage(self, full_path, image):
80 """Updates an existing image in GS, preserving permissions and metadata. 80 """Updates an existing image in GS, preserving permissions and metadata.
81 81
82 Args: 82 Args:
83 full_path: the path to the file in GS including the file extension. 83 full_path: the path to the file in GS including the file extension.
84 image: a RGB PIL.Image. 84 image: a RGB PIL.Image.
85 """ 85 """
86 self.cloud_bucket.UpdateFile(full_path, image_tools.EncodePNG(image)) 86 self.cloud_bucket.UpdateFile(full_path, image_tools.EncodePNG(image))
87 87
88 88
89 def UploadExpectation(self, expectation, images): 89 def GenerateExpectation(self, expectation, images):
90 """Creates and uploads an expectation to GS from a set of images and name. 90 """Creates and uploads an expectation to GS from a set of images and name.
91 91
92 This method generates a mask from the uploaded images, then 92 This method generates a mask from the uploaded images, then
93 uploads the mask and first of the images to GS as a expectation. 93 uploads the mask and first of the images to GS as a expectation.
94 94
95 Args: 95 Args:
96 expectation: name for this expectation, any existing expectation with the 96 expectation: name for this expectation, any existing expectation with the
97 name will be replaced. 97 name will be replaced.
98 images: a list of RGB encoded PIL.Images 98 images: a list of RGB encoded PIL.Images
99 """ 99 """
100 mask = image_tools.InflateMask(image_tools.CreateMask(images), 7) 100 mask = image_tools.InflateMask(image_tools.CreateMask(images), 7)
101 self.UploadImage( 101 self.UploadImage(
102 GetExpectationPath(expectation, 'expected.png'), images[0]) 102 GetExpectationPath(expectation, 'expected.png'), images[0])
103 self.UploadImage(GetExpectationPath(expectation, 'mask.png'), mask) 103 self.UploadImage(GetExpectationPath(expectation, 'mask.png'), mask)
104 104
105 def RunTest(self, test_run, expectation, actual): 105 def PerformComparison(self, test_run, expectation, actual):
106 """Runs an image comparison, and uploads discrepancies to GS. 106 """Runs an image comparison, and uploads discrepancies to GS.
107 107
108 Args: 108 Args:
109 test_run: the name of the test_run. 109 test_run: the name of the test_run.
110 expectation: the name of the expectation to use for comparison. 110 expectation: the name of the expectation to use for comparison.
111 actual: an RGB-encoded PIL.Image that is the actual result. 111 actual: an RGB-encoded PIL.Image that is the actual result.
112 112
113 Raises: 113 Raises:
114 cloud_bucket.NotFoundError: if the given expectation is not found. 114 cloud_bucket.NotFoundError: if the given expectation is not found.
115 """ 115 """
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
183 """Removes an expectation and all associated failures with that test. 183 """Removes an expectation and all associated failures with that test.
184 184
185 Args: 185 Args:
186 expectation: the name of the expectation to remove. 186 expectation: the name of the expectation to remove.
187 """ 187 """
188 test_paths = self.cloud_bucket.GetAllPaths( 188 test_paths = self.cloud_bucket.GetAllPaths(
189 GetExpectationPath(expectation)) 189 GetExpectationPath(expectation))
190 for path in test_paths: 190 for path in test_paths:
191 self.cloud_bucket.RemoveFile(path) 191 self.cloud_bucket.RemoveFile(path)
192 192
193 def UploadExpectationPinkOut(self, expectation, images, pint_out, rgb): 193 def GenerateExpectationPinkOut(self, expectation, images, pint_out, rgb):
194 """Uploads an ispy-test to GS with the pink_out workaround. 194 """Uploads an ispy-test to GS with the pink_out workaround.
195 195
196 Args: 196 Args:
197 expectation: the name of the expectation to be uploaded. 197 expectation: the name of the expectation to be uploaded.
198 images: a json encoded list of base64 encoded png images. 198 images: a json encoded list of base64 encoded png images.
199 pink_out: an image. 199 pink_out: an image.
200 RGB: a json list representing the RGB values of a color to mask out. 200 RGB: a json list representing the RGB values of a color to mask out.
201 """ 201 """
202 # convert the pink_out into a mask 202 # convert the pink_out into a mask
203 black = (0, 0, 0, 255) 203 black = (0, 0, 0, 255)
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
254 254
255 Args: 255 Args:
256 prefix: the prefix to filter files in GS by. 256 prefix: the prefix to filter files in GS by.
257 257
258 Returns: 258 Returns:
259 a list containing urls to all objects that started with 259 a list containing urls to all objects that started with
260 the prefix. 260 the prefix.
261 """ 261 """
262 return self.cloud_bucket.GetAllPaths(prefix) 262 return self.cloud_bucket.GetAllPaths(prefix)
263 263
OLDNEW
« no previous file with comments | « chrome/test/functional/ispy/client/chrome_utils_unittest.py ('k') | chrome/test/functional/ispy/common/ispy_utils_unittest.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698