diff options
author | epoger@google.com <epoger@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81> | 2012-05-15 14:58:53 +0000 |
---|---|---|
committer | epoger@google.com <epoger@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81> | 2012-05-15 14:58:53 +0000 |
commit | a2b793c4d159ccaffbf921a0339096f2c9c35560 (patch) | |
tree | 3033f269677268735ff05fbb10cc720e97cd2ec5 | |
parent | 415e76a76091d06a3eeb4087c378bfa76947bc58 (diff) |
Add self-test for skdiff, and remove date/time from skdiff output so it passes.
BUG=http://code.google.com/p/skia/issues/detail?id=612
Review URL: https://codereview.appspot.com/6198074
git-svn-id: http://skia.googlecode.com/svn/trunk@3938 2bbb7eff-a529-9590-31e7-b0007b416f81
-rw-r--r-- | tools/skdiff_main.cpp | 33 | ||||
-rwxr-xr-x | tools/tests/run.sh | 27 | ||||
-rw-r--r-- | tools/tests/skdiff/output-expected/different-bits-identical-pixels-diff.png | bin | 0 -> 2461 bytes | |||
-rw-r--r-- | tools/tests/skdiff/output-expected/different-bits-identical-pixels-white.png | bin | 0 -> 2461 bytes | |||
-rw-r--r-- | tools/tests/skdiff/output-expected/different-pixels-same-size-diff.png | bin | 0 -> 118646 bytes | |||
-rw-r--r-- | tools/tests/skdiff/output-expected/different-pixels-same-size-white.png | bin | 0 -> 4378 bytes | |||
-rw-r--r-- | tools/tests/skdiff/output-expected/different-sizes-diff.png | bin | 0 -> 6531 bytes | |||
-rw-r--r-- | tools/tests/skdiff/output-expected/different-sizes-white.png | bin | 0 -> 2461 bytes | |||
-rw-r--r-- | tools/tests/skdiff/output-expected/identical-bits-diff.png | bin | 0 -> 2461 bytes | |||
-rw-r--r-- | tools/tests/skdiff/output-expected/identical-bits-white.png | bin | 0 -> 2461 bytes | |||
-rw-r--r-- | tools/tests/skdiff/output-expected/index.html | 21 | ||||
-rw-r--r-- | tools/tests/skdiff/output-expected/stdout | 12 |
12 files changed, 78 insertions, 15 deletions
diff --git a/tools/skdiff_main.cpp b/tools/skdiff_main.cpp index f0930beb96..5ccc150b61 100644 --- a/tools/skdiff_main.cpp +++ b/tools/skdiff_main.cpp @@ -735,24 +735,27 @@ static void print_table_header (SkFILEWStream* stream, const int colorThreshold, const RecordArray& differences, const SkString &baseDir, - const SkString &comparisonDir) { - SkTime::DateTime dt; - SkTime::GetDateTime(&dt); + const SkString &comparisonDir, + bool doOutputDate=false) { stream->writeText("<table>\n"); stream->writeText("<tr><th>"); - stream->writeText("SkDiff run at "); - stream->writeDecAsText(dt.fHour); - stream->writeText(":"); - if (dt.fMinute < 10) { - stream->writeText("0"); - } - stream->writeDecAsText(dt.fMinute); - stream->writeText(":"); - if (dt.fSecond < 10) { - stream->writeText("0"); + if (doOutputDate) { + SkTime::DateTime dt; + SkTime::GetDateTime(&dt); + stream->writeText("SkDiff run at "); + stream->writeDecAsText(dt.fHour); + stream->writeText(":"); + if (dt.fMinute < 10) { + stream->writeText("0"); + } + stream->writeDecAsText(dt.fMinute); + stream->writeText(":"); + if (dt.fSecond < 10) { + stream->writeText("0"); + } + stream->writeDecAsText(dt.fSecond); + stream->writeText("<br>"); } - stream->writeDecAsText(dt.fSecond); - stream->writeText("<br>"); stream->writeDecAsText(matchCount); stream->writeText(" of "); stream->writeDecAsText(differences.count()); diff --git a/tools/tests/run.sh b/tools/tests/run.sh new file mode 100755 index 0000000000..d88740f399 --- /dev/null +++ b/tools/tests/run.sh @@ -0,0 +1,27 @@ +#!/bin/bash + +# Tests for our tools. +# TODO: for now, it only tests skdiff +# TODO: for now, assumes that it is being run from .../trunk + +# TODO: make it look in Release and/or Debug +SKDIFF_BINARY=out/Debug/skdiff + +function compare_directories { + diff --exclude=.* $1 $2 + if [ $? != 0 ]; then + echo "failed in: compare_directories $1 $2" + exit 1 + fi +} + +# Test skdiff... +# +SKDIFF_TESTDIR=tools/tests/skdiff +SKDIFF_OUTPUT_DIR=$SKDIFF_TESTDIR/output-actual +mkdir -p $SKDIFF_OUTPUT_DIR +$SKDIFF_BINARY $SKDIFF_TESTDIR/baseDir $SKDIFF_TESTDIR/comparisonDir \ + $SKDIFF_OUTPUT_DIR &>$SKDIFF_OUTPUT_DIR/stdout +compare_directories $SKDIFF_TESTDIR/output-expected $SKDIFF_OUTPUT_DIR + +echo "All tests passed." diff --git a/tools/tests/skdiff/output-expected/different-bits-identical-pixels-diff.png b/tools/tests/skdiff/output-expected/different-bits-identical-pixels-diff.png Binary files differnew file mode 100644 index 0000000000..170092865a --- /dev/null +++ b/tools/tests/skdiff/output-expected/different-bits-identical-pixels-diff.png diff --git a/tools/tests/skdiff/output-expected/different-bits-identical-pixels-white.png b/tools/tests/skdiff/output-expected/different-bits-identical-pixels-white.png Binary files differnew file mode 100644 index 0000000000..170092865a --- /dev/null +++ b/tools/tests/skdiff/output-expected/different-bits-identical-pixels-white.png diff --git a/tools/tests/skdiff/output-expected/different-pixels-same-size-diff.png b/tools/tests/skdiff/output-expected/different-pixels-same-size-diff.png Binary files differnew file mode 100644 index 0000000000..dbd706349d --- /dev/null +++ b/tools/tests/skdiff/output-expected/different-pixels-same-size-diff.png diff --git a/tools/tests/skdiff/output-expected/different-pixels-same-size-white.png b/tools/tests/skdiff/output-expected/different-pixels-same-size-white.png Binary files differnew file mode 100644 index 0000000000..10d8c55a56 --- /dev/null +++ b/tools/tests/skdiff/output-expected/different-pixels-same-size-white.png diff --git a/tools/tests/skdiff/output-expected/different-sizes-diff.png b/tools/tests/skdiff/output-expected/different-sizes-diff.png Binary files differnew file mode 100644 index 0000000000..ecba8036f9 --- /dev/null +++ b/tools/tests/skdiff/output-expected/different-sizes-diff.png diff --git a/tools/tests/skdiff/output-expected/different-sizes-white.png b/tools/tests/skdiff/output-expected/different-sizes-white.png Binary files differnew file mode 100644 index 0000000000..170092865a --- /dev/null +++ b/tools/tests/skdiff/output-expected/different-sizes-white.png diff --git a/tools/tests/skdiff/output-expected/identical-bits-diff.png b/tools/tests/skdiff/output-expected/identical-bits-diff.png Binary files differnew file mode 100644 index 0000000000..170092865a --- /dev/null +++ b/tools/tests/skdiff/output-expected/identical-bits-diff.png diff --git a/tools/tests/skdiff/output-expected/identical-bits-white.png b/tools/tests/skdiff/output-expected/identical-bits-white.png Binary files differnew file mode 100644 index 0000000000..170092865a --- /dev/null +++ b/tools/tests/skdiff/output-expected/identical-bits-white.png diff --git a/tools/tests/skdiff/output-expected/index.html b/tools/tests/skdiff/output-expected/index.html new file mode 100644 index 0000000000..07ffc2f72f --- /dev/null +++ b/tools/tests/skdiff/output-expected/index.html @@ -0,0 +1,21 @@ +<html> +<body> +<table> +<tr><th>4 of 8 images matched exactly.<br></th> +<th>every different pixel shown in white</th> +<th>color difference at each pixel</th> +<th>tools/tests/skdiff/baseDir/</th> +<th>tools/tests/skdiff/comparisonDir/</th> +</tr> +<tr> +<td>different-sizes.png<br>Image sizes differ</td><td align=center>[image size mismatch, so no diff to display]</td><td align=center>[image size mismatch, so no diff to display]</td><td><a href="../../../../tools/tests/skdiff/baseDir/different-sizes.png"><img src="../../../../tools/tests/skdiff/baseDir/different-sizes.png" height="240px"></a></td><td><a href="../../../../tools/tests/skdiff/comparisonDir/different-sizes.png"><img src="../../../../tools/tests/skdiff/comparisonDir/different-sizes.png" height="240px"></a></td></tr> +<tr> +<td>different-pixels-same-size.png<br> 97.9926% of pixels differ + ( 42.8911% weighted)<br>Average color mismatch 89<br>Max color mismatch 239</td><td><a href="different-pixels-same-size-white.png"><img src="different-pixels-same-size-white.png" height="240px"></a></td><td><a href="different-pixels-same-size-diff.png"><img src="different-pixels-same-size-diff.png" height="240px"></a></td><td><a href="../../../../tools/tests/skdiff/baseDir/different-pixels-same-size.png"><img src="../../../../tools/tests/skdiff/baseDir/different-pixels-same-size.png" height="240px"></a></td><td><a href="../../../../tools/tests/skdiff/comparisonDir/different-pixels-same-size.png"><img src="../../../../tools/tests/skdiff/comparisonDir/different-pixels-same-size.png" height="240px"></a></td></tr> +<tr> +<td>missing-from-baseDir.png<br></td><td>N/A</td><td>N/A</td><td>N/A</td><td><a href="../../../../tools/tests/skdiff/comparisonDir/missing-from-baseDir.png"><img src="../../../../tools/tests/skdiff/comparisonDir/missing-from-baseDir.png" height="240px"></a></td></tr> +<tr> +<td>missing-from-comparisonDir.png<br></td><td>N/A</td><td>N/A</td><td><a href="../../../../tools/tests/skdiff/baseDir/missing-from-comparisonDir.png"><img src="../../../../tools/tests/skdiff/baseDir/missing-from-comparisonDir.png" height="240px"></a></td><td>N/A</td></tr> +</table> +</body> +</html> diff --git a/tools/tests/skdiff/output-expected/stdout b/tools/tests/skdiff/output-expected/stdout new file mode 100644 index 0000000000..90abea3fc5 --- /dev/null +++ b/tools/tests/skdiff/output-expected/stdout @@ -0,0 +1,12 @@ +ERROR: no codec found for <tools/tests/skdiff/baseDir/different-bits-unknown-format.xyz> +ERROR: no codec found for <tools/tests/skdiff/baseDir/identical-bits-unknown-format.xyz> +baseDir is [tools/tests/skdiff/baseDir/] +comparisonDir is [tools/tests/skdiff/comparisonDir/] +writing diffs to outputDir is [tools/tests/skdiff/output-actual/] +Missing in baseDir: + missing-from-baseDir.png +Missing in comparisonDir: + missing-from-comparisonDir.png +4 of 8 images matched. +Maximum pixel intensity mismatch 239 +Largest area mismatch was 100.00% of pixels |