summaryrefslogtreecommitdiffstats
path: root/Tools/Scripts/webkitpy/layout_tests/test_types/image_diff.py
diff options
context:
space:
mode:
Diffstat (limited to 'Tools/Scripts/webkitpy/layout_tests/test_types/image_diff.py')
-rw-r--r--Tools/Scripts/webkitpy/layout_tests/test_types/image_diff.py117
1 files changed, 0 insertions, 117 deletions
diff --git a/Tools/Scripts/webkitpy/layout_tests/test_types/image_diff.py b/Tools/Scripts/webkitpy/layout_tests/test_types/image_diff.py
deleted file mode 100644
index 1d7e107..0000000
--- a/Tools/Scripts/webkitpy/layout_tests/test_types/image_diff.py
+++ /dev/null
@@ -1,117 +0,0 @@
-#!/usr/bin/env python
-# Copyright (C) 2010 Google Inc. All rights reserved.
-#
-# Redistribution and use in source and binary forms, with or without
-# modification, are permitted provided that the following conditions are
-# met:
-#
-# * Redistributions of source code must retain the above copyright
-# notice, this list of conditions and the following disclaimer.
-# * Redistributions in binary form must reproduce the above
-# copyright notice, this list of conditions and the following disclaimer
-# in the documentation and/or other materials provided with the
-# distribution.
-# * Neither the name of Google Inc. nor the names of its
-# contributors may be used to endorse or promote products derived from
-# this software without specific prior written permission.
-#
-# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
-# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
-# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
-# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
-# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
-# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
-# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
-# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
-# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
-# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
-# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-
-"""Compares the image output of a test to the expected image output.
-
-Compares hashes for the generated and expected images. If the output doesn't
-match, returns FailureImageHashMismatch and outputs both hashes into the layout
-test results directory.
-"""
-
-import errno
-import logging
-
-from webkitpy.layout_tests.layout_package import test_failures
-from webkitpy.layout_tests.test_types import test_type_base
-
-# Cache whether we have the image_diff executable available.
-_compare_available = True
-_compare_msg_printed = False
-
-_log = logging.getLogger("webkitpy.layout_tests.test_types.image_diff")
-
-
-class ImageDiff(test_type_base.TestTypeBase):
-
- def _copy_image(self, filename, actual_image, expected_image):
- self.write_output_files(filename, '.png',
- output=actual_image, expected=expected_image,
- encoding=None, print_text_diffs=False)
-
- def _copy_image_hash(self, filename, actual_image_hash, expected_image_hash):
- self.write_output_files(filename, '.checksum',
- actual_image_hash, expected_image_hash,
- encoding="ascii", print_text_diffs=False)
-
- def _create_diff_image(self, port, filename, actual_image, expected_image):
- """Creates the visual diff of the expected/actual PNGs.
-
- Returns True if the images are different.
- """
- diff_filename = self.output_filename(filename,
- self.FILENAME_SUFFIX_COMPARE)
- return port.diff_image(actual_image, expected_image, diff_filename)
-
- def compare_output(self, port, filename, options, actual_driver_output,
- expected_driver_output):
- """Implementation of CompareOutput that checks the output image and
- checksum against the expected files from the LayoutTest directory.
- """
- failures = []
-
- # If we didn't produce a hash file, this test must be text-only.
- if actual_driver_output.image_hash is None:
- return failures
-
- if not expected_driver_output.image:
- # Report a missing expected PNG file.
- self._copy_image(filename, actual_driver_output.image, expected_image=None)
- self._copy_image_hash(filename, actual_driver_output.image_hash,
- expected_driver_output.image_hash)
- failures.append(test_failures.FailureMissingImage())
- return failures
- if not expected_driver_output.image_hash:
- # Report a missing expected checksum file.
- self._copy_image(filename, actual_driver_output.image,
- expected_driver_output.image)
- self._copy_image_hash(filename, actual_driver_output.image_hash,
- expected_image_hash=None)
- failures.append(test_failures.FailureMissingImageHash())
- return failures
-
- if actual_driver_output.image_hash == expected_driver_output.image_hash:
- # Hash matched (no diff needed, okay to return).
- return failures
-
- self._copy_image(filename, actual_driver_output.image,
- expected_driver_output.image)
- self._copy_image_hash(filename, actual_driver_output.image_hash,
- expected_driver_output.image_hash)
-
- # Even though we only use the result in one codepath below but we
- # still need to call CreateImageDiff for other codepaths.
- images_are_different = self._create_diff_image(port, filename,
- actual_driver_output.image,
- expected_driver_output.image)
- if not images_are_different:
- failures.append(test_failures.FailureImageHashIncorrect())
- else:
- failures.append(test_failures.FailureImageHashMismatch())
-
- return failures