<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>[181579] trunk</title>
</head>
<body>

<style type="text/css"><!--
#msg dl.meta { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dl.meta dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer, #logmsg { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt;  }
#msg dl a { font-weight: bold}
#msg dl a:link    { color:#fc3; }
#msg dl a:active  { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; }
#msg pre { overflow: auto; background: #ffc; border: 1px #fa0 solid; padding: 6px; }
#logmsg { background: #ffc; border: 1px #fa0 solid; padding: 1em 1em 0 1em; }
#logmsg p, #logmsg pre, #logmsg blockquote { margin: 0 0 1em 0; }
#logmsg p, #logmsg li, #logmsg dt, #logmsg dd { line-height: 14pt; }
#logmsg h1, #logmsg h2, #logmsg h3, #logmsg h4, #logmsg h5, #logmsg h6 { margin: .5em 0; }
#logmsg h1:first-child, #logmsg h2:first-child, #logmsg h3:first-child, #logmsg h4:first-child, #logmsg h5:first-child, #logmsg h6:first-child { margin-top: 0; }
#logmsg ul, #logmsg ol { padding: 0; list-style-position: inside; margin: 0 0 0 1em; }
#logmsg ul { text-indent: -1em; padding-left: 1em; }#logmsg ol { text-indent: -1.5em; padding-left: 1.5em; }
#logmsg > ul, #logmsg > ol { margin: 0 0 1em 0; }
#logmsg pre { background: #eee; padding: 1em; }
#logmsg blockquote { border: 1px solid #fa0; border-left-width: 10px; padding: 1em 1em 0 1em; background: white;}
#logmsg dl { margin: 0; }
#logmsg dt { font-weight: bold; }
#logmsg dd { margin: 0; padding: 0 0 0.5em 0; }
#logmsg dd:before { content:'\00bb';}
#logmsg table { border-spacing: 0px; border-collapse: collapse; border-top: 4px solid #fa0; border-bottom: 1px solid #fa0; background: #fff; }
#logmsg table th { text-align: left; font-weight: normal; padding: 0.2em 0.5em; border-top: 1px dotted #fa0; }
#logmsg table td { text-align: right; border-top: 1px dotted #fa0; padding: 0.2em 0.5em; }
#logmsg table thead th { text-align: center; border-bottom: 1px solid #fa0; }
#logmsg table th.Corner { text-align: left; }
#logmsg hr { border: none 0; border-top: 2px dashed #fa0; height: 1px; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; }
#patch { width: 100%; }
#patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff  {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;}
#patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;}
#patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;}
#patch .lines, .info {color:#888;background:#fff;}
--></style>
<div id="msg">
<dl class="meta">
<dt>Revision</dt> <dd><a href="http://trac.webkit.org/projects/webkit/changeset/181579">181579</a></dd>
<dt>Author</dt> <dd>ap@apple.com</dd>
<dt>Date</dt> <dd>2015-03-16 14:52:40 -0700 (Mon, 16 Mar 2015)</dd>
</dl>

<h3>Log Message</h3>
<pre>Add tolerance to WebAudio tests
https://bugs.webkit.org/show_bug.cgi?id=142676

Reviewed by Tim Horton.

Tools:

* Scripts/webkitpy/common/wavediff.py: Added. Based on Jer Noble's work.

* Scripts/webkitpy/layout_tests/controllers/test_result_writer.py:
(TestResultWriter.create_audio_diff_and_write_result):
* Scripts/webkitpy/layout_tests/models/test_failures.py:
(FailureAudio.write_failure):
* Scripts/webkitpy/port/base.py:
(Port.do_audio_results_differ):
Diff audio failures.

* Scripts/webkitpy/port/test.py: Added a test for the tolerance, fixed existing
tests to use real parseable WAV data, and got rid of base64, which there didn't
seem to have been any reason for.

LayoutTests:

* fast/harness/results.html: Display a diff link for audio tests, as we now have the diff.

* platform/mac/TestExpectations: Unmark tests that should now pass everywhere.</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkLayoutTestsChangeLog">trunk/LayoutTests/ChangeLog</a></li>
<li><a href="#trunkLayoutTestsfastharnessresultshtml">trunk/LayoutTests/fast/harness/results.html</a></li>
<li><a href="#trunkLayoutTestsplatformmacTestExpectations">trunk/LayoutTests/platform/mac/TestExpectations</a></li>
<li><a href="#trunkToolsChangeLog">trunk/Tools/ChangeLog</a></li>
<li><a href="#trunkToolsScriptswebkitpylayout_testscontrollerstest_result_writerpy">trunk/Tools/Scripts/webkitpy/layout_tests/controllers/test_result_writer.py</a></li>
<li><a href="#trunkToolsScriptswebkitpylayout_testsmodelstest_failurespy">trunk/Tools/Scripts/webkitpy/layout_tests/models/test_failures.py</a></li>
<li><a href="#trunkToolsScriptswebkitpyportbasepy">trunk/Tools/Scripts/webkitpy/port/base.py</a></li>
<li><a href="#trunkToolsScriptswebkitpyporttestpy">trunk/Tools/Scripts/webkitpy/port/test.py</a></li>
</ul>

<h3>Added Paths</h3>
<ul>
<li><a href="#trunkToolsScriptswebkitpycommonwavediffpy">trunk/Tools/Scripts/webkitpy/common/wavediff.py</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkLayoutTestsChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/ChangeLog (181578 => 181579)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/ChangeLog        2015-03-16 21:24:48 UTC (rev 181578)
+++ trunk/LayoutTests/ChangeLog        2015-03-16 21:52:40 UTC (rev 181579)
</span><span class="lines">@@ -1,3 +1,14 @@
</span><ins>+2015-03-16  Alexey Proskuryakov  &lt;ap@apple.com&gt;
+
+        Add tolerance to WebAudio tests
+        https://bugs.webkit.org/show_bug.cgi?id=142676
+
+        Reviewed by Tim Horton.
+
+        * fast/harness/results.html: Display a diff link for audio tests, as we now have the diff.
+
+        * platform/mac/TestExpectations: Unmark tests that should now pass everywhere.
+
</ins><span class="cx"> 2015-03-16  Chris Dumez  &lt;cdumez@apple.com&gt;
</span><span class="cx"> 
</span><span class="cx">         Make DatabaseContext suspendable if there is no pending database activity
</span></span></pre></div>
<a id="trunkLayoutTestsfastharnessresultshtml"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/fast/harness/results.html (181578 => 181579)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/fast/harness/results.html        2015-03-16 21:24:48 UTC (rev 181578)
+++ trunk/LayoutTests/fast/harness/results.html        2015-03-16 21:52:40 UTC (rev 181579)
</span><span class="lines">@@ -659,6 +659,7 @@
</span><span class="cx">     if (actual.indexOf('AUDIO') != -1) {
</span><span class="cx">         row += resultLink(testPrefix, '-expected.wav', 'expected audio');
</span><span class="cx">         row += resultLink(testPrefix, '-actual.wav', 'actual audio');
</span><ins>+        row += resultLink(testPrefix, '-diff.txt', 'textual diff');
</ins><span class="cx">     }
</span><span class="cx"> 
</span><span class="cx">     if (actual.indexOf('MISSING') != -1) {
</span></span></pre></div>
<a id="trunkLayoutTestsplatformmacTestExpectations"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/platform/mac/TestExpectations (181578 => 181579)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/platform/mac/TestExpectations        2015-03-16 21:24:48 UTC (rev 181578)
+++ trunk/LayoutTests/platform/mac/TestExpectations        2015-03-16 21:52:40 UTC (rev 181579)
</span><span class="lines">@@ -617,7 +617,6 @@
</span><span class="cx"> webaudio/mediastreamaudiosourcenode.html [ Failure ]
</span><span class="cx"> webaudio/codec-tests/vorbis/ [ WontFix ]
</span><span class="cx"> webkit.org/b/119467 webaudio/audiobuffersource-loop-points.html [ Skip ]
</span><del>-[ Mavericks ] webaudio/codec-tests/wav/24bit-22khz-resample.html [ Failure ]
</del><span class="cx"> 
</span><span class="cx"> # Text Autosizing is not enabled.
</span><span class="cx"> webkit.org/b/84186 fast/text-autosizing
</span><span class="lines">@@ -759,14 +758,10 @@
</span><span class="cx"> # webkit.org/b/100846, webkit.org/b/136715
</span><span class="cx"> inspector-protocol/debugger
</span><span class="cx"> 
</span><del>-webkit.org/b/123490 [ Mavericks ] webaudio/oscillator-sawtooth.html [ Pass Failure ]
-
</del><span class="cx"> webkit.org/b/124311 compositing/regions/transform-transparent-positioned-video-inside-region.html [ ImageOnlyFailure ]
</span><span class="cx"> 
</span><span class="cx"> webkit.org/b/124321 [ Mavericks ] animations/resume-after-page-cache.html [ Pass Failure ]
</span><span class="cx"> 
</span><del>-webkit.org/b/121646 webaudio/delaynode-max-default-delay.html [ Pass Failure ]
-
</del><span class="cx"> # These fast/forms/select tests open a pop-up menu (visible on screen even when using run-webkit-tests), and get stuck in its nested event loop.
</span><span class="cx"> webkit.org/b/87748 fast/forms/select/optgroup-clicking.html [ Skip ]
</span><span class="cx"> webkit.org/b/73304 fast/forms/select/menulist-popup-crash.html [ Skip ]
</span><span class="lines">@@ -1090,10 +1085,6 @@
</span><span class="cx"> webkit.org/b/137157 [ Release ] inspector/page/main-frame-resource.html [ Pass Failure ]
</span><span class="cx"> [ Debug ] inspector/page/main-frame-resource.html [ Pass Failure Slow ]
</span><span class="cx"> 
</span><del>-# FIXME: Needs bugzilla (&lt;rdar://problem/15393179&gt;)
-[ Yosemite+ ] webaudio/codec-tests/wav/24bit-22khz-resample.html [ Failure ]
-[ Yosemite+ ] webaudio/oscillator-sawtooth.html [ Pass Failure ]
-
</del><span class="cx"> webkit.org/b/137505 media/track/track-forced-subtitles-in-band.html [ Failure Pass ]
</span><span class="cx"> 
</span><span class="cx"> # FIXME: Needs bugzilla (&lt;rdar://problem/15971968&gt;)
</span></span></pre></div>
<a id="trunkToolsChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Tools/ChangeLog (181578 => 181579)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Tools/ChangeLog        2015-03-16 21:24:48 UTC (rev 181578)
+++ trunk/Tools/ChangeLog        2015-03-16 21:52:40 UTC (rev 181579)
</span><span class="lines">@@ -1,5 +1,26 @@
</span><span class="cx"> 2015-03-16  Alexey Proskuryakov  &lt;ap@apple.com&gt;
</span><span class="cx"> 
</span><ins>+        Add tolerance to WebAudio tests
+        https://bugs.webkit.org/show_bug.cgi?id=142676
+
+        Reviewed by Tim Horton.
+
+        * Scripts/webkitpy/common/wavediff.py: Added. Based on Jer Noble's work.
+
+        * Scripts/webkitpy/layout_tests/controllers/test_result_writer.py:
+        (TestResultWriter.create_audio_diff_and_write_result):
+        * Scripts/webkitpy/layout_tests/models/test_failures.py:
+        (FailureAudio.write_failure):
+        * Scripts/webkitpy/port/base.py:
+        (Port.do_audio_results_differ):
+        Diff audio failures.
+
+        * Scripts/webkitpy/port/test.py: Added a test for the tolerance, fixed existing
+        tests to use real parseable WAV data, and got rid of base64, which there didn't
+        seem to have been any reason for.
+
+2015-03-16  Alexey Proskuryakov  &lt;ap@apple.com&gt;
+
</ins><span class="cx">         [Mac] fast/forms/text-control-intrinsic-widths.html fails when MS Office is installed
</span><span class="cx">         https://bugs.webkit.org/show_bug.cgi?id=142720
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkToolsScriptswebkitpycommonwavediffpy"></a>
<div class="addfile"><h4>Added: trunk/Tools/Scripts/webkitpy/common/wavediff.py (0 => 181579)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Tools/Scripts/webkitpy/common/wavediff.py                                (rev 0)
+++ trunk/Tools/Scripts/webkitpy/common/wavediff.py        2015-03-16 21:52:40 UTC (rev 181579)
</span><span class="lines">@@ -0,0 +1,112 @@
</span><ins>+# Copyright (C) 2015 Apple 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:
+# 1.  Redistributions of source code must retain the above copyright
+#     notice, this list of conditions and the following disclaimer.
+# 2.  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.
+#
+# THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS 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 APPLE INC. OR ITS 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.
+
+import StringIO
+import struct
+import sys
+import tempfile
+import wave
+
+
+class WaveDiff(object):
+    _paramNames = ('Number of channels', 'Sample width', 'Sample rate', 'Number of frames', 'Compression type', 'Compression name')
+
+    # Audio effect processing is intrinsically imprecise, so we need to always allow tolerance.
+    _tolerance = 1
+
+    def __init__(self, in1, in2):
+        if isinstance(in1, file):
+            waveFile1 = wave.open(in1, 'rb')
+        else:
+            waveFile1 = wave.open(StringIO.StringIO(in1), 'rb')
+        if isinstance(in2, file):
+            waveFile1 = wave.open(in2, 'rb')
+        else:
+            waveFile2 = wave.open(StringIO.StringIO(in2), 'rb')
+
+        params1 = waveFile1.getparams()
+        params2 = waveFile2.getparams()
+
+        self._diff = ''
+
+        self._filesAreIdentical = not sum(map(self._diffParam, params1, params2, self._paramNames))
+        self._filesAreIdenticalWithinTolerance = self._filesAreIdentical
+
+        if not self._filesAreIdentical:
+            return
+
+        # Metadata is identical, compare the content now.
+
+        channelCount1 = waveFile1.getnchannels()
+        frameCount1 = waveFile1.getnframes()
+        sampleWidth1 = waveFile1.getsampwidth()
+        channelCount2 = waveFile2.getnchannels()
+        frameCount2 = waveFile2.getnframes()
+        sampleWidth2 = waveFile2.getsampwidth()
+
+        allData1 = self._readSamples(waveFile1, sampleWidth1, frameCount1 * channelCount1)
+        allData2 = self._readSamples(waveFile2, sampleWidth2, frameCount2 * channelCount2)
+        results = map(self._diffSample, allData1, allData2, xrange(max(frameCount1 * channelCount1, frameCount2 * channelCount2)))
+
+        cumulativeSampleDiff = sum(results)
+        differingSampleCount = len(filter(bool, results))
+        self._filesAreIdentical = not differingSampleCount
+        self._filesAreIdenticalWithinTolerance = not len(filter(lambda x: x &gt; self._tolerance, results))
+
+        if differingSampleCount:
+            self._diff += '\n'
+            self._diff += 'Total differing samples: %d\n' % differingSampleCount
+            self._diff += 'Percentage of differing samples: %0.3f%%\n' % (100 * float(differingSampleCount) / max(frameCount1, frameCount2))
+            self._diff += 'Cumulative sample difference: %d\n' % cumulativeSampleDiff
+            self._diff += 'Average sample difference: %f\n' % (float(cumulativeSampleDiff) / differingSampleCount)
+
+    def _diffParam(self, param1, param2, paramName):
+        if param1 == param2:
+            return False
+        self._diff += paramName + '\n'
+        self._diff += '&lt; %s\n' % str(param1)
+        self._diff += '---\n'
+        self._diff += '&gt; %s\n' % str(param2)
+        return True
+
+    @staticmethod
+    def _readSamples(file, sampleWidth, nSamples):
+        allFrames = file.readframes(nSamples)
+        unpackFormat = 'b' if sampleWidth == 1 else 'h'
+        return struct.unpack('&lt;%d%s' % (nSamples, unpackFormat), allFrames)
+
+    def _diffSample(self, data1, data2, i):
+        if (data1 != data2):
+            self._diff += 'Sample #%d\n' % i
+            self._diff += '&lt; %d\n' % data1
+            self._diff += '---\n'
+            self._diff += '&gt; %d\n' % data2
+        return abs(data1 - data2)
+
+    def filesAreIdentical(self):
+        return self._filesAreIdentical
+
+    def filesAreIdenticalWithinTolerance(self):
+        return self._filesAreIdenticalWithinTolerance
+
+    def diffText(self):
+        return self._diff
</ins></span></pre></div>
<a id="trunkToolsScriptswebkitpylayout_testscontrollerstest_result_writerpy"></a>
<div class="modfile"><h4>Modified: trunk/Tools/Scripts/webkitpy/layout_tests/controllers/test_result_writer.py (181578 => 181579)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Tools/Scripts/webkitpy/layout_tests/controllers/test_result_writer.py        2015-03-16 21:24:48 UTC (rev 181578)
+++ trunk/Tools/Scripts/webkitpy/layout_tests/controllers/test_result_writer.py        2015-03-16 21:52:40 UTC (rev 181579)
</span><span class="lines">@@ -29,6 +29,7 @@
</span><span class="cx"> 
</span><span class="cx"> import logging
</span><span class="cx"> 
</span><ins>+from webkitpy.common.wavediff import WaveDiff
</ins><span class="cx"> from webkitpy.layout_tests.models import test_failures
</span><span class="cx"> 
</span><span class="cx"> 
</span><span class="lines">@@ -161,6 +162,10 @@
</span><span class="cx">     def write_audio_files(self, actual_audio, expected_audio):
</span><span class="cx">         self.write_output_files('.wav', actual_audio, expected_audio)
</span><span class="cx"> 
</span><ins>+    def create_audio_diff_and_write_result(self, actual_audio, expected_audio):
+        diff_filename = self.output_filename(self.FILENAME_SUFFIX_DIFF + '.txt')
+        self._write_text_file(diff_filename, WaveDiff(expected_audio, actual_audio).diffText())
+
</ins><span class="cx">     def write_image_files(self, actual_image, expected_image):
</span><span class="cx">         self.write_output_files('.png', actual_image, expected_image)
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkToolsScriptswebkitpylayout_testsmodelstest_failurespy"></a>
<div class="modfile"><h4>Modified: trunk/Tools/Scripts/webkitpy/layout_tests/models/test_failures.py (181578 => 181579)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Tools/Scripts/webkitpy/layout_tests/models/test_failures.py        2015-03-16 21:24:48 UTC (rev 181578)
+++ trunk/Tools/Scripts/webkitpy/layout_tests/models/test_failures.py        2015-03-16 21:52:40 UTC (rev 181579)
</span><span class="lines">@@ -122,6 +122,7 @@
</span><span class="cx"> class FailureAudio(TestFailure):
</span><span class="cx">     def write_failure(self, writer, driver_output, expected_driver_output, port):
</span><span class="cx">         writer.write_audio_files(driver_output.audio, expected_driver_output.audio)
</span><ins>+        writer.create_audio_diff_and_write_result(driver_output.audio, expected_driver_output.audio)
</ins><span class="cx"> 
</span><span class="cx"> 
</span><span class="cx"> class FailureTimeout(TestFailure):
</span></span></pre></div>
<a id="trunkToolsScriptswebkitpyportbasepy"></a>
<div class="modfile"><h4>Modified: trunk/Tools/Scripts/webkitpy/port/base.py (181578 => 181579)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Tools/Scripts/webkitpy/port/base.py        2015-03-16 21:24:48 UTC (rev 181578)
+++ trunk/Tools/Scripts/webkitpy/port/base.py        2015-03-16 21:52:40 UTC (rev 181579)
</span><span class="lines">@@ -50,6 +50,7 @@
</span><span class="cx"> from webkitpy.common.system import path
</span><span class="cx"> from webkitpy.common.system.executive import ScriptError
</span><span class="cx"> from webkitpy.common.system.systemhost import SystemHost
</span><ins>+from webkitpy.common.wavediff import WaveDiff
</ins><span class="cx"> from webkitpy.common.webkit_finder import WebKitFinder
</span><span class="cx"> from webkitpy.layout_tests.models.test_configuration import TestConfiguration
</span><span class="cx"> from webkitpy.port import config as port_config
</span><span class="lines">@@ -282,7 +283,9 @@
</span><span class="cx">         return expected_text != actual_text
</span><span class="cx"> 
</span><span class="cx">     def do_audio_results_differ(self, expected_audio, actual_audio):
</span><del>-        return expected_audio != actual_audio
</del><ins>+        if expected_audio == actual_audio:
+            return False
+        return not WaveDiff(expected_audio, actual_audio).filesAreIdenticalWithinTolerance()
</ins><span class="cx"> 
</span><span class="cx">     def diff_image(self, expected_contents, actual_contents, tolerance=None):
</span><span class="cx">         &quot;&quot;&quot;Compare two images and return a tuple of an image diff, a percentage difference (0-100), and an error string.
</span></span></pre></div>
<a id="trunkToolsScriptswebkitpyporttestpy"></a>
<div class="modfile"><h4>Modified: trunk/Tools/Scripts/webkitpy/port/test.py (181578 => 181579)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Tools/Scripts/webkitpy/port/test.py        2015-03-16 21:24:48 UTC (rev 181578)
+++ trunk/Tools/Scripts/webkitpy/port/test.py        2015-03-16 21:52:40 UTC (rev 181579)
</span><span class="lines">@@ -26,7 +26,6 @@
</span><span class="cx"> # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
</span><span class="cx"> # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
</span><span class="cx"> 
</span><del>-import base64
</del><span class="cx"> import sys
</span><span class="cx"> import time
</span><span class="cx"> 
</span><span class="lines">@@ -99,7 +98,7 @@
</span><span class="cx"> #
</span><span class="cx"> # These numbers may need to be updated whenever we add or delete tests.
</span><span class="cx"> #
</span><del>-TOTAL_TESTS = 71
</del><ins>+TOTAL_TESTS = 72
</ins><span class="cx"> TOTAL_SKIPS = 9
</span><span class="cx"> TOTAL_RETRIES = 14
</span><span class="cx"> 
</span><span class="lines">@@ -107,6 +106,9 @@
</span><span class="cx"> UNEXPECTED_FAILURES = 17
</span><span class="cx"> 
</span><span class="cx"> def unit_test_list():
</span><ins>+    silent_audio = &quot;RIFF2\x00\x00\x00WAVEfmt \x10\x00\x00\x00\x01\x00\x01\x00\x22\x56\x00\x00\x44\xAC\x00\x00\x02\x00\x10\x00data\x0E\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00&quot;
+    silent_audio_with_single_bit_difference = &quot;RIFF2\x00\x00\x00WAVEfmt \x10\x00\x00\x00\x01\x00\x01\x00\x22\x56\x00\x00\x44\xAC\x00\x00\x02\x00\x10\x00data\x0E\x00\x00\x00\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00&quot;
+    audio2 = &quot;RIFF2\x00\x00\x00WAVEfmt \x10\x00\x00\x00\x01\x00\x01\x00\x22\x56\x00\x00\x44\xAC\x00\x00\x02\x00\x10\x00data\x0E\x00\x00\x00\x40\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00&quot;
</ins><span class="cx">     tests = TestList()
</span><span class="cx">     tests.add('failures/expected/crash.html', crash=True)
</span><span class="cx">     tests.add('failures/expected/exception.html', exception=True)
</span><span class="lines">@@ -120,7 +122,7 @@
</span><span class="cx">               actual_checksum='image_checksum_fail-checksum',
</span><span class="cx">               actual_image='image_checksum_fail-png')
</span><span class="cx">     tests.add('failures/expected/audio.html',
</span><del>-              actual_audio=base64.b64encode('audio_fail-wav'), expected_audio='audio-wav',
</del><ins>+              actual_audio=silent_audio, expected_audio=audio2,
</ins><span class="cx">               actual_text=None, expected_text=None,
</span><span class="cx">               actual_image=None, expected_image=None,
</span><span class="cx">               actual_checksum=None)
</span><span class="lines">@@ -181,10 +183,15 @@
</span><span class="cx">     tests.add('passes/error.html', error='stuff going to stderr')
</span><span class="cx">     tests.add('passes/image.html')
</span><span class="cx">     tests.add('passes/audio.html',
</span><del>-              actual_audio=base64.b64encode('audio-wav'), expected_audio='audio-wav',
</del><ins>+              actual_audio=silent_audio, expected_audio=silent_audio,
</ins><span class="cx">               actual_text=None, expected_text=None,
</span><span class="cx">               actual_image=None, expected_image=None,
</span><span class="cx">               actual_checksum=None)
</span><ins>+    tests.add('passes/audio-tolerance.html',
+              actual_audio=silent_audio_with_single_bit_difference, expected_audio=silent_audio,
+              actual_text=None, expected_text=None,
+              actual_image=None, expected_image=None,
+              actual_checksum=None)
</ins><span class="cx">     tests.add('passes/platform_image.html')
</span><span class="cx">     tests.add('passes/checksum_in_image.html',
</span><span class="cx">               expected_image='tEXtchecksum\x00checksum_in_image-checksum')
</span><span class="lines">@@ -558,7 +565,7 @@
</span><span class="cx">             actual_text = actual_text + ' ' + ' '.join(test_args)
</span><span class="cx"> 
</span><span class="cx">         if test.actual_audio:
</span><del>-            audio = base64.b64decode(test.actual_audio)
</del><ins>+            audio = test.actual_audio
</ins><span class="cx">         crashed_process_name = None
</span><span class="cx">         crashed_pid = None
</span><span class="cx">         if test.crash:
</span></span></pre>
</div>
</div>

</body>
</html>