Changeset 172368 in webkit


Ignore:
Timestamp:
Aug 8, 2014 5:23:38 PM (10 years ago)
Author:
Simon Fraser
Message:

Load the layout test result image diff HTML from a file, rather than having it inline in webkitpy
https://bugs.webkit.org/show_bug.cgi?id=135780

Reviewed by Dan Bates.

Tools:

Pull the HTML for the image diff file into a separate file, for easier hackability.

  • Scripts/webkitpy/layout_tests/controllers/test_result_writer.py:

(TestResultWriter.write_image_diff_files):

LayoutTests:

Add image-diff-template.html and expected result (crazy, but this is what we do
for results.html too).

  • fast/harness/image-diff-template-expected.txt: Added.
  • fast/harness/image-diff-template.html: Added.
Location:
trunk
Files:
2 added
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r172365 r172368  
     12014-08-08  Simon Fraser  <simon.fraser@apple.com>
     2
     3        Load the layout test result image diff HTML from a file, rather than having it inline in webkitpy
     4        https://bugs.webkit.org/show_bug.cgi?id=135780
     5
     6        Reviewed by Dan Bates.
     7       
     8        Add image-diff-template.html and expected result (crazy, but this is what we do
     9        for results.html too).
     10
     11        * fast/harness/image-diff-template-expected.txt: Added.
     12        * fast/harness/image-diff-template.html: Added.
     13
    1142014-08-08  Simon Fraser  <simon.fraser@apple.com>
    215
  • trunk/Tools/ChangeLog

    r172353 r172368  
     12014-08-08  Simon Fraser  <simon.fraser@apple.com>
     2
     3        Load the layout test result image diff HTML from a file, rather than having it inline in webkitpy
     4        https://bugs.webkit.org/show_bug.cgi?id=135780
     5
     6        Reviewed by Dan Bates.
     7       
     8        Pull the HTML for the image diff file into a separate file, for easier hackability.
     9
     10        * Scripts/webkitpy/layout_tests/controllers/test_result_writer.py:
     11        (TestResultWriter.write_image_diff_files):
     12
    1132014-08-08  Mark Lam  <mark.lam@apple.com>
    214
  • trunk/Tools/Scripts/webkitpy/layout_tests/controllers/test_result_writer.py

    r161881 r172368  
    169169        self._write_binary_file(diff_filename, image_diff)
    170170
    171         diffs_html_filename = self.output_filename(self.FILENAME_SUFFIX_IMAGE_DIFFS_HTML)
     171        base_dir = self._port.path_from_webkit_base('LayoutTests', 'fast', 'harness')
     172        image_diff_file = self._filesystem.read_text_file(self._filesystem.join(base_dir, 'image-diff-template.html'))
     173
    172174        # FIXME: old-run-webkit-tests shows the diff percentage as the text contents of the "diff" link.
    173175        # FIXME: old-run-webkit-tests include a link to the test file.
    174         html = """<!DOCTYPE HTML>
    175 <html>
    176 <head>
    177 <title>%(title)s</title>
    178 <style>.label{font-weight:bold}</style>
    179 </head>
    180 <body>
    181 Difference between images: <a href="%(diff_filename)s">diff</a><br>
    182 <div class=imageText></div>
    183 <div class=imageContainer data-prefix="%(prefix)s">Loading...</div>
    184 <script>
    185 (function() {
    186     var preloadedImageCount = 0;
    187     function preloadComplete() {
    188         ++preloadedImageCount;
    189         if (preloadedImageCount < 2)
    190             return;
    191         toggleImages();
    192         setInterval(toggleImages, 2000)
    193     }
    194 
    195     function preloadImage(url) {
    196         image = new Image();
    197         image.addEventListener('load', preloadComplete);
    198         image.src = url;
    199         return image;
    200     }
    201 
    202     function toggleImages() {
    203         if (text.textContent == 'Expected Image') {
    204             text.textContent = 'Actual Image';
    205             container.replaceChild(actualImage, container.firstChild);
    206         } else {
    207             text.textContent = 'Expected Image';
    208             container.replaceChild(expectedImage, container.firstChild);
    209         }
    210     }
    211 
    212     var text = document.querySelector('.imageText');
    213     var container = document.querySelector('.imageContainer');
    214     var actualImage = preloadImage(container.getAttribute('data-prefix') + '-actual.png');
    215     var expectedImage = preloadImage(container.getAttribute('data-prefix') + '-expected.png');
    216 })();
    217 </script>
    218 </body>
    219 </html>
    220 """ % {
     176        html = image_diff_file % {
    221177            'title': self._test_name,
    222178            'diff_filename': self._output_testname(self.FILENAME_SUFFIX_IMAGE_DIFF),
    223179            'prefix': self._output_testname(''),
    224180        }
     181
     182        diffs_html_filename = self.output_filename(self.FILENAME_SUFFIX_IMAGE_DIFFS_HTML)
    225183        self._filesystem.write_text_file(diffs_html_filename, html)
    226184
Note: See TracChangeset for help on using the changeset viewer.