Skip to content

Commit

Permalink
Allow masks to be created from one image.
Browse files Browse the repository at this point in the history
Modify image_tools to allow lists of one image to be used
to create a mask.

BUG=None
NOTRY=True

Review URL: https://codereview.chromium.org/98563005

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@238995 0039d316-1c4b-4281-b951-d872f2087c98
  • Loading branch information
baxley@chromium.org committed Dec 5, 2013
1 parent 27a0ea4 commit 297d1f8
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 4 deletions.
8 changes: 4 additions & 4 deletions chrome/test/functional/ispy/common/image_tools.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,18 +87,18 @@ def CreateMask(images):
everywhere else.
Args:
images: the images to compute the mask from.
images: list of images to compute the mask from.
Returns:
an image of only black and white pixels where white pixels represent
areas in the input images that have differences.
Raises:
Exception: if the images passed in are not of the same size.
Exception: if fewer than two images are passed in.
Exception: if fewer than one image is passed in.
"""
if len(images) < 2:
raise Exception('mask must be created from two or more images.')
if not images:
raise Exception('mask must be created from one or more images.')
mask = Image.new('RGBA', images[0].size, (0, 0, 0, 255))
image = images[0]
for other_image in images[1:]:
Expand Down
7 changes: 7 additions & 0 deletions chrome/test/functional/ispy/common/ispy_utils_unittest.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ def testGenerateExpectation(self):
# Upload some tests to the datastore.
self.ispy_utils.GenerateExpectation('test', [self.white, self.black])
self.ispy_utils.GenerateExpectation('test1', [self.black, self.black])
self.ispy_utils.GenerateExpectation('test2', [self.black])
# Confirm that the tests were successfully uploaded.
self.assertEquals(self.bucket.datastore[
ispy_utils.GetExpectationPath('test', 'expected.png')],
Expand All @@ -92,6 +93,12 @@ def testGenerateExpectation(self):
self.assertEquals(self.bucket.datastore[
ispy_utils.GetExpectationPath('test1', 'mask.png')],
image_tools.EncodePNG(self.black))
self.assertEquals(self.bucket.datastore[
ispy_utils.GetExpectationPath('test2', 'expected.png')],
image_tools.EncodePNG(self.black))
self.assertEquals(self.bucket.datastore[
ispy_utils.GetExpectationPath('test2', 'mask.png')],
image_tools.EncodePNG(self.black))

def testPerformComparison(self):
self.bucket.Reset()
Expand Down

0 comments on commit 297d1f8

Please sign in to comment.