aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorGravatar commit-bot@chromium.org <commit-bot@chromium.org@2bbb7eff-a529-9590-31e7-b0007b416f81>2014-04-10 15:39:02 +0000
committerGravatar commit-bot@chromium.org <commit-bot@chromium.org@2bbb7eff-a529-9590-31e7-b0007b416f81>2014-04-10 15:39:02 +0000
commit24c568c1597de9f54df8cea3b46f2e93028a5aec (patch)
tree2113a9b210751beef6aa6fc99ce98743fe76089e
parentef93d294ef545c91028262478e4f1c7c2ed456b8 (diff)
add explicit filepaths to render_pictures JSON summary
BUG=skia:2230,skia:1942 R=rmistry@google.com Author: epoger@google.com Review URL: https://codereview.chromium.org/226293002 git-svn-id: http://skia.googlecode.com/svn/trunk@14133 2bbb7eff-a529-9590-31e7-b0007b416f81
-rw-r--r--tools/PictureRenderer.cpp127
-rw-r--r--tools/PictureRenderer.h20
-rw-r--r--tools/picture_utils.cpp11
-rw-r--r--tools/picture_utils.h11
-rw-r--r--tools/render_pictures_main.cpp36
-rw-r--r--tools/skimage_main.cpp7
-rwxr-xr-xtools/tests/render_pictures_test.py266
7 files changed, 353 insertions, 125 deletions
diff --git a/tools/PictureRenderer.cpp b/tools/PictureRenderer.cpp
index 2afd3745d1..f71b9544e0 100644
--- a/tools/PictureRenderer.cpp
+++ b/tools/PictureRenderer.cpp
@@ -22,6 +22,7 @@
#include "SkImageEncoder.h"
#include "SkMaskFilter.h"
#include "SkMatrix.h"
+#include "SkOSFile.h"
#include "SkPicture.h"
#include "SkPictureUtils.h"
#include "SkPixelRef.h"
@@ -50,32 +51,62 @@ enum {
kDefaultTileHeight = 256
};
-/* TODO(epoger): These constants are already maintained in 2 other places:
- * gm/gm_json.py and gm/gm_expectations.cpp. We shouldn't add yet a third place.
+/*
+ * TODO(epoger): Make constant strings consistent instead of mixing hypenated and camel-caps.
+ *
+ * TODO(epoger): Similar constants are already maintained in 2 other places:
+ * gm/gm_json.py and gm/gm_expectations.cpp. We shouldn't add yet a third place.
* Figure out a way to share the definitions instead.
+ *
+ * Note that, as of https://codereview.chromium.org/226293002 , the JSON
+ * schema used here has started to differ from the one in gm_expectations.cpp .
+ * TODO(epoger): Consider getting GM and render_pictures to use the same JSON
+ * output module.
*/
-const static char kJsonKey_ActualResults[] = "actual-results";
-const static char kJsonKey_ActualResults_NoComparison[] = "no-comparison";
-const static char kJsonKey_Hashtype_Bitmap_64bitMD5[] = "bitmap-64bitMD5";
-
-void ImageResultsSummary::add(const char *testName, uint64_t hash) {
- Json::Value jsonTypeValuePair;
- jsonTypeValuePair.append(Json::Value(kJsonKey_Hashtype_Bitmap_64bitMD5));
- jsonTypeValuePair.append(Json::UInt64(hash));
- fActualResultsNoComparison[testName] = jsonTypeValuePair;
+const static char kJsonKey_ActualResults[] = "actual-results";
+const static char kJsonKey_Header[] = "header";
+const static char kJsonKey_Header_Type[] = "type";
+const static char kJsonKey_Header_Revision[] = "revision"; // unique within Type
+const static char kJsonKey_Image_ChecksumAlgorithm[] = "checksumAlgorithm";
+const static char kJsonKey_Image_ChecksumValue[] = "checksumValue";
+const static char kJsonKey_Image_ComparisonResult[] = "comparisonResult";
+const static char kJsonKey_Image_Filepath[] = "filepath";
+const static char kJsonKey_Source_TiledImages[] = "tiled-images";
+const static char kJsonKey_Source_WholeImage[] = "whole-image";
+// Values (not keys) that are written out by this JSON generator
+const static char kJsonValue_Header_Type[] = "ChecksummedImages";
+const static int kJsonValue_Header_Revision = 1;
+const static char kJsonValue_Image_ChecksumAlgorithm_Bitmap64bitMD5[] = "bitmap-64bitMD5";
+const static char kJsonValue_Image_ComparisonResult_NoComparison[] = "no-comparison";
+
+void ImageResultsSummary::add(const char *sourceName, const char *fileName, uint64_t hash,
+ const int *tileNumber) {
+ Json::Value image;
+ image[kJsonKey_Image_ChecksumAlgorithm] = kJsonValue_Image_ChecksumAlgorithm_Bitmap64bitMD5;
+ image[kJsonKey_Image_ChecksumValue] = Json::UInt64(hash);
+ image[kJsonKey_Image_ComparisonResult] = kJsonValue_Image_ComparisonResult_NoComparison;
+ image[kJsonKey_Image_Filepath] = fileName;
+ if (NULL == tileNumber) {
+ fActualResults[sourceName][kJsonKey_Source_WholeImage] = image;
+ } else {
+ fActualResults[sourceName][kJsonKey_Source_TiledImages][*tileNumber] = image;
+ }
}
-void ImageResultsSummary::add(const char *testName, const SkBitmap& bitmap) {
+void ImageResultsSummary::add(const char *sourceName, const char *fileName, const SkBitmap& bitmap,
+ const int *tileNumber) {
uint64_t hash;
SkAssertResult(SkBitmapHasher::ComputeDigest(bitmap, &hash));
- this->add(testName, hash);
+ this->add(sourceName, fileName, hash, tileNumber);
}
void ImageResultsSummary::writeToFile(const char *filename) {
- Json::Value actualResults;
- actualResults[kJsonKey_ActualResults_NoComparison] = fActualResultsNoComparison;
+ Json::Value header;
+ header[kJsonKey_Header_Type] = kJsonValue_Header_Type;
+ header[kJsonKey_Header_Revision] = kJsonValue_Header_Revision;
Json::Value root;
- root[kJsonKey_ActualResults] = actualResults;
+ root[kJsonKey_Header] = header;
+ root[kJsonKey_ActualResults] = fActualResults;
std::string jsonStdString = root.toStyledString();
SkFILEWStream stream(filename);
stream.write(jsonStdString.c_str(), jsonStdString.length());
@@ -304,7 +335,7 @@ uint32_t PictureRenderer::recordFlags() {
* @param inputFilename If we are writing out a binary image, use this to build its filename.
* @param jsonSummaryPtr If not null, add image results to this summary.
* @param useChecksumBasedFilenames If true, use checksum-based filenames when writing to disk.
- * @param numberToAppend If not null, append this number to the filename.
+ * @param tileNumberPtr If not null, which tile number this image contains.
* @return bool True if the Canvas is written to a file.
*
* TODO(epoger): Right now, all canvases must pass through this function in order to be appended
@@ -320,7 +351,7 @@ uint32_t PictureRenderer::recordFlags() {
*/
static bool write(SkCanvas* canvas, const SkString& outputDir, const SkString& inputFilename,
ImageResultsSummary *jsonSummaryPtr, bool useChecksumBasedFilenames,
- const int* numberToAppend=NULL) {
+ const int* tileNumberPtr=NULL) {
SkASSERT(canvas != NULL);
if (NULL == canvas) {
return false;
@@ -337,40 +368,61 @@ static bool write(SkCanvas* canvas, const SkString& outputDir, const SkString& i
canvas->readPixels(&bitmap, 0, 0);
sk_tools::force_all_opaque(bitmap);
- SkString outputFilename(inputFilename);
- outputFilename.remove(outputFilename.size() - 4, 4);
- if (NULL != numberToAppend) {
- outputFilename.appendf("%i", *numberToAppend);
- }
- outputFilename.append(".png");
+ SkString escapedInputFilename(inputFilename);
+ replace_char(&escapedInputFilename, '.', '_');
+
// TODO(epoger): what about including the config type within outputFilename? That way,
// we could combine results of different config types without conflicting filenames.
-
- if (NULL != jsonSummaryPtr) {
+ SkString outputFilename;
+ const char *outputSubdirPtr = NULL;
+ if (useChecksumBasedFilenames) {
SkASSERT(!generatedHash);
SkAssertResult(SkBitmapHasher::ComputeDigest(bitmap, &hash));
generatedHash = true;
- jsonSummaryPtr->add(outputFilename.c_str(), hash);
+ outputSubdirPtr = escapedInputFilename.c_str();
+ outputFilename.set(kJsonValue_Image_ChecksumAlgorithm_Bitmap64bitMD5);
+ outputFilename.append("_");
+ outputFilename.appendU64(hash);
+ } else {
+ outputFilename.set(escapedInputFilename);
+ if (NULL != tileNumberPtr) {
+ outputFilename.append("-tile");
+ outputFilename.appendS32(*tileNumberPtr);
+ }
}
+ outputFilename.append(".png");
- // Update outputFilename AFTER adding to JSON summary, but BEFORE writing out the image file.
- if (useChecksumBasedFilenames) {
+ if (NULL != jsonSummaryPtr) {
if (!generatedHash) {
SkAssertResult(SkBitmapHasher::ComputeDigest(bitmap, &hash));
generatedHash = true;
}
- outputFilename.set(kJsonKey_Hashtype_Bitmap_64bitMD5);
- outputFilename.append("_");
- outputFilename.appendU64(hash);
- outputFilename.append(".png");
+
+ SkString outputRelativePath;
+ if (outputSubdirPtr) {
+ outputRelativePath.set(outputSubdirPtr);
+ outputRelativePath.append("/"); // always use "/", even on Windows
+ outputRelativePath.append(outputFilename);
+ } else {
+ outputRelativePath.set(outputFilename);
+ }
+
+ jsonSummaryPtr->add(inputFilename.c_str(), outputRelativePath.c_str(),
+ hash, tileNumberPtr);
}
SkASSERT(!outputDir.isEmpty()); // TODO(epoger): we want to remove this constraint,
// as noted above
- SkString fullPathname;
- make_filepath(&fullPathname, outputDir, outputFilename);
- return SkImageEncoder::EncodeFile(fullPathname.c_str(), bitmap, SkImageEncoder::kPNG_Type, 100);
+ SkString dirPath;
+ if (outputSubdirPtr) {
+ dirPath = SkOSPath::SkPathJoin(outputDir.c_str(), outputSubdirPtr);
+ sk_mkdir(dirPath.c_str());
+ } else {
+ dirPath.set(outputDir);
+ }
+ SkString fullPath = SkOSPath::SkPathJoin(dirPath.c_str(), outputFilename.c_str());
+ return SkImageEncoder::EncodeFile(fullPath.c_str(), bitmap, SkImageEncoder::kPNG_Type, 100);
}
///////////////////////////////////////////////////////////////////////////////////////////////
@@ -394,8 +446,7 @@ bool RecordPictureRenderer::render(SkBitmap** out) {
replayer->endRecording();
if (!fOutputDir.isEmpty()) {
// Record the new picture as a new SKP with PNG encoded bitmaps.
- SkString skpPath;
- make_filepath(&skpPath, fOutputDir, fInputFilename);
+ SkString skpPath = SkOSPath::SkPathJoin(fOutputDir.c_str(), fInputFilename.c_str());
SkFILEWStream stream(skpPath.c_str());
replayer->serialize(&stream, &encode_bitmap_to_data);
return true;
diff --git a/tools/PictureRenderer.h b/tools/PictureRenderer.h
index 7c5a9da1f0..26bdb7790f 100644
--- a/tools/PictureRenderer.h
+++ b/tools/PictureRenderer.h
@@ -44,20 +44,26 @@ class TiledPictureRenderer;
class ImageResultsSummary {
public:
/**
- * Adds this bitmap hash to the summary of results.
+ * Adds this image to the summary of results.
*
- * @param testName name of the test
+ * @param sourceName name of the source file that generated this result
+ * @param fileName relative path to the image output file on local disk
* @param hash hash to store
+ * @param tileNumber if not NULL, ptr to tile number
*/
- void add(const char *testName, uint64_t hash);
+ void add(const char *sourceName, const char *fileName, uint64_t hash,
+ const int *tileNumber=NULL);
/**
- * Adds this bitmap's hash to the summary of results.
+ * Adds this image to the summary of results.
*
- * @param testName name of the test
+ * @param sourceName name of the source file that generated this result
+ * @param fileName relative path to the image output file on local disk
* @param bitmap bitmap to store the hash of
+ * @param tileNumber if not NULL, ptr to tile number
*/
- void add(const char *testName, const SkBitmap& bitmap);
+ void add(const char *sourceName, const char *fileName, const SkBitmap& bitmap,
+ const int *tileNumber=NULL);
/**
* Writes the summary (as constructed so far) to a file.
@@ -67,7 +73,7 @@ public:
void writeToFile(const char *filename);
private:
- Json::Value fActualResultsNoComparison;
+ Json::Value fActualResults;
};
class PictureRenderer : public SkRefCnt {
diff --git a/tools/picture_utils.cpp b/tools/picture_utils.cpp
index ee189ad785..4bcdf8a964 100644
--- a/tools/picture_utils.cpp
+++ b/tools/picture_utils.cpp
@@ -36,6 +36,17 @@ namespace sk_tools {
}
}
+ void replace_char(SkString* str, const char oldChar, const char newChar) {
+ if (NULL == str) {
+ return;
+ }
+ for (size_t i = 0; i < str->size(); ++i) {
+ if (oldChar == str->operator[](i)) {
+ str->operator[](i) = newChar;
+ }
+ }
+ }
+
void make_filepath(SkString* path, const SkString& dir, const SkString& name) {
size_t len = dir.size();
path->set(dir);
diff --git a/tools/picture_utils.h b/tools/picture_utils.h
index 4c2f6e546a..02eee285d0 100644
--- a/tools/picture_utils.h
+++ b/tools/picture_utils.h
@@ -24,14 +24,25 @@ namespace sk_tools {
// not be on the GPU.
void force_all_opaque(const SkBitmap& bitmap);
+ /**
+ * Replaces all instances of oldChar with newChar in str.
+ *
+ * TODO: This function appears here and in skimage_main.cpp ;
+ * we should add the implementation to src/core/SkString.cpp, write tests for it,
+ * and remove it from elsewhere.
+ */
+ void replace_char(SkString* str, const char oldChar, const char newChar);
+
// Creates a posix style filepath by concatenating name onto dir with a
// forward slash into path.
+ // TODO(epoger): delete in favor of SkOSPath::SkPathJoin()?
void make_filepath(SkString* path, const SkString&, const SkString& name);
// Returns the last part of the path (file name or leaf directory name)
//
// This basically just looks for a foward slash or backslash (windows
// only).
+ // TODO(epoger): delete in favor of SkOSPath::SkBasename()?
void get_basename(SkString* basename, const SkString& path);
// Returns true if the string ends with %
diff --git a/tools/render_pictures_main.cpp b/tools/render_pictures_main.cpp
index 7563074e5b..7ebbdbd3aa 100644
--- a/tools/render_pictures_main.cpp
+++ b/tools/render_pictures_main.cpp
@@ -48,13 +48,6 @@ DEFINE_bool(bench_record, false, "If true, drop into an infinite loop of recordi
DEFINE_bool(preprocess, false, "If true, perform device specific preprocessing before rendering.");
-static void make_output_filepath(SkString* path, const SkString& dir,
- const SkString& name) {
- sk_tools::make_filepath(path, dir, name);
- // Remove ".skp"
- path->remove(path->size() - 4, 4);
-}
-
////////////////////////////////////////////////////////////////////////////////////////////////////
/**
@@ -348,28 +341,21 @@ static bool render_picture(const SkString& inputPath, const SkString* outputDir,
if (FLAGS_writeWholeImage) {
sk_tools::force_all_opaque(*bitmap);
+ // TODO(epoger): It would be better for the filename (without outputDir) to be passed in
+ // here, and used both for the checksum file and writing into outputDir.
+ SkString inputFilename, outputPath;
+ sk_tools::get_basename(&inputFilename, inputPath);
+ sk_tools::make_filepath(&outputPath, *outputDir, inputFilename);
+ sk_tools::replace_char(&outputPath, '.', '_');
+ outputPath.append(".png");
+
if (NULL != jsonSummaryPtr) {
- // TODO(epoger): This is a hacky way of constructing the filename associated with the
- // image checksum; we basically are repeating the logic of make_output_filepath()
- // and code below here, within here.
- // It would be better for the filename (without outputDir) to be passed in here,
- // and used both for the checksum file and writing into outputDir.
- //
- // TODO(epoger): what about including the config type within hashFilename? That way,
- // we could combine results of different config types without conflicting filenames.
- SkString hashFilename;
- sk_tools::get_basename(&hashFilename, inputPath);
- hashFilename.remove(hashFilename.size() - 4, 4); // Remove ".skp"
- hashFilename.append(".png");
- jsonSummaryPtr->add(hashFilename.c_str(), *bitmap);
+ SkString outputFileBasename;
+ sk_tools::get_basename(&outputFileBasename, outputPath);
+ jsonSummaryPtr->add(inputFilename.c_str(), outputFileBasename.c_str(), *bitmap);
}
if (NULL != outputDir) {
- SkString inputFilename;
- sk_tools::get_basename(&inputFilename, inputPath);
- SkString outputPath;
- make_output_filepath(&outputPath, *outputDir, inputFilename);
- outputPath.append(".png");
if (!SkImageEncoder::EncodeFile(outputPath.c_str(), *bitmap,
SkImageEncoder::kPNG_Type, 100)) {
SkDebugf("Failed to draw the picture.\n");
diff --git a/tools/skimage_main.cpp b/tools/skimage_main.cpp
index 634a71d46a..e5610ea569 100644
--- a/tools/skimage_main.cpp
+++ b/tools/skimage_main.cpp
@@ -464,8 +464,11 @@ static void test_stream_without_length(const char srcPath[], SkImageDecoder* cod
#endif // defined(SK_BUILD_FOR_ANDROID) || defined(SK_BUILD_FOR_UNIX)
/**
- * Replace all instances of oldChar with newChar in str.
- * TODO: Add this function to SkString and write tests for it.
+ * Replaces all instances of oldChar with newChar in str.
+ *
+ * TODO: This function appears here and in picture_utils.[cpp|h] ;
+ * we should add the implementation to src/core/SkString.cpp, write tests for it,
+ * and remove it from elsewhere.
*/
static void replace_char(SkString* str, const char oldChar, const char newChar) {
if (NULL == str) {
diff --git a/tools/tests/render_pictures_test.py b/tools/tests/render_pictures_test.py
index 162531a6ad..3ebed93578 100755
--- a/tools/tests/render_pictures_test.py
+++ b/tools/tests/render_pictures_test.py
@@ -21,6 +21,11 @@ import base_unittest
# Maximum length of text diffs to show when tests fail
MAX_DIFF_LENGTH = 30000
+EXPECTED_HEADER_CONTENTS = {
+ "type" : "ChecksummedImages",
+ "revision" : 1,
+}
+
class RenderPicturesTest(base_unittest.TestCase):
@@ -38,9 +43,9 @@ class RenderPicturesTest(base_unittest.TestCase):
output_json_path = os.path.join(self._temp_dir, 'output.json')
self._generate_skps()
# TODO(epoger): I noticed that when this is run without --writePath being
- # specified, this test writes red.png and green.png to the current working
+ # specified, this test writes red_skp.png and green_skp.png to the current
# directory. We should fix that... if --writePath is not specified, this
- # probably shouldn't write out red.png and green.png at all!
+ # probably shouldn't write out red_skp.png and green_skp.png at all!
self._run_render_pictures(['-r', self._input_skp_dir,
'--bbh', 'grid', '256', '256',
'--mode', 'tile', '256', '256',
@@ -48,18 +53,31 @@ class RenderPicturesTest(base_unittest.TestCase):
'--writePath', self._temp_dir,
'--writeWholeImage'])
expected_summary_dict = {
+ "header" : EXPECTED_HEADER_CONTENTS,
"actual-results" : {
- "no-comparison" : {
+ "red.skp": {
# Manually verified: 640x400 red rectangle with black border
- "red.png" : [ "bitmap-64bitMD5", 11092453015575919668 ],
+ "whole-image": {
+ "checksumAlgorithm" : "bitmap-64bitMD5",
+ "checksumValue" : 11092453015575919668,
+ "comparisonResult" : "no-comparison",
+ "filepath" : "red_skp.png",
+ },
+ },
+ "green.skp": {
# Manually verified: 640x400 green rectangle with black border
- "green.png" : [ "bitmap-64bitMD5", 8891695120562235492 ],
+ "whole-image": {
+ "checksumAlgorithm" : "bitmap-64bitMD5",
+ "checksumValue" : 8891695120562235492,
+ "comparisonResult" : "no-comparison",
+ "filepath" : "green_skp.png",
+ },
}
}
}
self._assert_json_contents(output_json_path, expected_summary_dict)
self._assert_directory_contents(
- self._temp_dir, ['red.png', 'green.png', 'output.json'])
+ self._temp_dir, ['red_skp.png', 'green_skp.png', 'output.json'])
def test_untiled(self):
"""Run without tiles."""
@@ -68,19 +86,34 @@ class RenderPicturesTest(base_unittest.TestCase):
self._run_render_pictures(['-r', self._input_skp_dir,
'--writePath', self._temp_dir,
'--writeJsonSummaryPath', output_json_path])
+ # TODO(epoger): These expectations are the same as for above unittest.
+ # Define the expectations once, and share them.
expected_summary_dict = {
+ "header" : EXPECTED_HEADER_CONTENTS,
"actual-results" : {
- "no-comparison" : {
+ "red.skp": {
# Manually verified: 640x400 red rectangle with black border
- "red.png" : ["bitmap-64bitMD5", 11092453015575919668],
+ "whole-image": {
+ "checksumAlgorithm" : "bitmap-64bitMD5",
+ "checksumValue" : 11092453015575919668,
+ "comparisonResult" : "no-comparison",
+ "filepath" : "red_skp.png",
+ },
+ },
+ "green.skp": {
# Manually verified: 640x400 green rectangle with black border
- "green.png" : ["bitmap-64bitMD5", 8891695120562235492],
+ "whole-image": {
+ "checksumAlgorithm" : "bitmap-64bitMD5",
+ "checksumValue" : 8891695120562235492,
+ "comparisonResult" : "no-comparison",
+ "filepath" : "green_skp.png",
+ },
}
}
}
self._assert_json_contents(output_json_path, expected_summary_dict)
self._assert_directory_contents(
- self._temp_dir, ['red.png', 'green.png', 'output.json'])
+ self._temp_dir, ['red_skp.png', 'green_skp.png', 'output.json'])
def test_untiled_writeChecksumBasedFilenames(self):
"""Same as test_untiled, but with --writeChecksumBasedFilenames."""
@@ -91,20 +124,37 @@ class RenderPicturesTest(base_unittest.TestCase):
'--writePath', self._temp_dir,
'--writeJsonSummaryPath', output_json_path])
expected_summary_dict = {
+ "header" : EXPECTED_HEADER_CONTENTS,
"actual-results" : {
- "no-comparison" : {
+ "red.skp": {
# Manually verified: 640x400 red rectangle with black border
- "red.png" : ["bitmap-64bitMD5", 11092453015575919668],
+ "whole-image": {
+ "checksumAlgorithm" : "bitmap-64bitMD5",
+ "checksumValue" : 11092453015575919668,
+ "comparisonResult" : "no-comparison",
+ "filepath" : "red_skp/bitmap-64bitMD5_11092453015575919668.png",
+ },
+ },
+ "green.skp": {
# Manually verified: 640x400 green rectangle with black border
- "green.png" : ["bitmap-64bitMD5", 8891695120562235492],
+ "whole-image": {
+ "checksumAlgorithm" : "bitmap-64bitMD5",
+ "checksumValue" : 8891695120562235492,
+ "comparisonResult" : "no-comparison",
+ "filepath" : "green_skp/bitmap-64bitMD5_8891695120562235492.png",
+ },
}
}
}
self._assert_json_contents(output_json_path, expected_summary_dict)
+ self._assert_directory_contents(self._temp_dir, [
+ 'red_skp', 'green_skp', 'output.json'])
+ self._assert_directory_contents(
+ os.path.join(self._temp_dir, 'red_skp'),
+ ['bitmap-64bitMD5_11092453015575919668.png'])
self._assert_directory_contents(
- self._temp_dir, ['bitmap-64bitMD5_11092453015575919668.png',
- 'bitmap-64bitMD5_8891695120562235492.png',
- 'output.json'])
+ os.path.join(self._temp_dir, 'green_skp'),
+ ['bitmap-64bitMD5_8891695120562235492.png'])
def test_untiled_validate(self):
"""Same as test_untiled, but with --validate.
@@ -135,9 +185,8 @@ class RenderPicturesTest(base_unittest.TestCase):
self._run_render_pictures(['-r', self._input_skp_dir,
'--writeJsonSummaryPath', output_json_path])
expected_summary_dict = {
- "actual-results" : {
- "no-comparison" : None,
- }
+ "header" : EXPECTED_HEADER_CONTENTS,
+ "actual-results" : None,
}
self._assert_json_contents(output_json_path, expected_summary_dict)
@@ -151,35 +200,90 @@ class RenderPicturesTest(base_unittest.TestCase):
'--writePath', self._temp_dir,
'--writeJsonSummaryPath', output_json_path])
expected_summary_dict = {
+ "header" : EXPECTED_HEADER_CONTENTS,
"actual-results" : {
- "no-comparison" : {
+ "red.skp": {
# Manually verified these 6 images, all 256x256 tiles,
# consistent with a tiled version of the 640x400 red rect
# with black borders.
- "red0.png" : ["bitmap-64bitMD5", 5815827069051002745],
- "red1.png" : ["bitmap-64bitMD5", 9323613075234140270],
- "red2.png" : ["bitmap-64bitMD5", 16670399404877552232],
- "red3.png" : ["bitmap-64bitMD5", 2507897274083364964],
- "red4.png" : ["bitmap-64bitMD5", 7325267995523877959],
- "red5.png" : ["bitmap-64bitMD5", 2181381724594493116],
+ "tiled-images": [{
+ "checksumAlgorithm" : "bitmap-64bitMD5",
+ "checksumValue" : 5815827069051002745,
+ "comparisonResult" : "no-comparison",
+ "filepath" : "red_skp-tile0.png",
+ }, {
+ "checksumAlgorithm" : "bitmap-64bitMD5",
+ "checksumValue" : 9323613075234140270,
+ "comparisonResult" : "no-comparison",
+ "filepath" : "red_skp-tile1.png",
+ }, {
+ "checksumAlgorithm" : "bitmap-64bitMD5",
+ "checksumValue" : 16670399404877552232,
+ "comparisonResult" : "no-comparison",
+ "filepath" : "red_skp-tile2.png",
+ }, {
+ "checksumAlgorithm" : "bitmap-64bitMD5",
+ "checksumValue" : 2507897274083364964,
+ "comparisonResult" : "no-comparison",
+ "filepath" : "red_skp-tile3.png",
+ }, {
+ "checksumAlgorithm" : "bitmap-64bitMD5",
+ "checksumValue" : 7325267995523877959,
+ "comparisonResult" : "no-comparison",
+ "filepath" : "red_skp-tile4.png",
+ }, {
+ "checksumAlgorithm" : "bitmap-64bitMD5",
+ "checksumValue" : 2181381724594493116,
+ "comparisonResult" : "no-comparison",
+ "filepath" : "red_skp-tile5.png",
+ }],
+ },
+ "green.skp": {
# Manually verified these 6 images, all 256x256 tiles,
# consistent with a tiled version of the 640x400 green rect
# with black borders.
- "green0.png" : ["bitmap-64bitMD5", 12587324416545178013],
- "green1.png" : ["bitmap-64bitMD5", 7624374914829746293],
- "green2.png" : ["bitmap-64bitMD5", 5686489729535631913],
- "green3.png" : ["bitmap-64bitMD5", 7980646035555096146],
- "green4.png" : ["bitmap-64bitMD5", 17817086664365875131],
- "green5.png" : ["bitmap-64bitMD5", 10673669813016809363],
+ "tiled-images": [{
+ "checksumAlgorithm" : "bitmap-64bitMD5",
+ "checksumValue" : 12587324416545178013,
+ "comparisonResult" : "no-comparison",
+ "filepath" : "green_skp-tile0.png",
+ }, {
+ "checksumAlgorithm" : "bitmap-64bitMD5",
+ "checksumValue" : 7624374914829746293,
+ "comparisonResult" : "no-comparison",
+ "filepath" : "green_skp-tile1.png",
+ }, {
+ "checksumAlgorithm" : "bitmap-64bitMD5",
+ "checksumValue" : 5686489729535631913,
+ "comparisonResult" : "no-comparison",
+ "filepath" : "green_skp-tile2.png",
+ }, {
+ "checksumAlgorithm" : "bitmap-64bitMD5",
+ "checksumValue" : 7980646035555096146,
+ "comparisonResult" : "no-comparison",
+ "filepath" : "green_skp-tile3.png",
+ }, {
+ "checksumAlgorithm" : "bitmap-64bitMD5",
+ "checksumValue" : 17817086664365875131,
+ "comparisonResult" : "no-comparison",
+ "filepath" : "green_skp-tile4.png",
+ }, {
+ "checksumAlgorithm" : "bitmap-64bitMD5",
+ "checksumValue" : 10673669813016809363,
+ "comparisonResult" : "no-comparison",
+ "filepath" : "green_skp-tile5.png",
+ }],
}
}
}
self._assert_json_contents(output_json_path, expected_summary_dict)
self._assert_directory_contents(
self._temp_dir,
- ['red0.png', 'red1.png', 'red2.png', 'red3.png', 'red4.png', 'red5.png',
- 'green0.png', 'green1.png', 'green2.png', 'green3.png', 'green4.png',
- 'green5.png', 'output.json'])
+ ['red_skp-tile0.png', 'red_skp-tile1.png', 'red_skp-tile2.png',
+ 'red_skp-tile3.png', 'red_skp-tile4.png', 'red_skp-tile5.png',
+ 'green_skp-tile0.png', 'green_skp-tile1.png', 'green_skp-tile2.png',
+ 'green_skp-tile3.png', 'green_skp-tile4.png', 'green_skp-tile5.png',
+ 'output.json'])
def test_tiled_writeChecksumBasedFilenames(self):
"""Same as test_tiled, but with --writeChecksumBasedFilenames."""
@@ -192,45 +296,101 @@ class RenderPicturesTest(base_unittest.TestCase):
'--writePath', self._temp_dir,
'--writeJsonSummaryPath', output_json_path])
expected_summary_dict = {
+ "header" : EXPECTED_HEADER_CONTENTS,
"actual-results" : {
- "no-comparison" : {
+ "red.skp": {
# Manually verified these 6 images, all 256x256 tiles,
# consistent with a tiled version of the 640x400 red rect
# with black borders.
- "red0.png" : ["bitmap-64bitMD5", 5815827069051002745],
- "red1.png" : ["bitmap-64bitMD5", 9323613075234140270],
- "red2.png" : ["bitmap-64bitMD5", 16670399404877552232],
- "red3.png" : ["bitmap-64bitMD5", 2507897274083364964],
- "red4.png" : ["bitmap-64bitMD5", 7325267995523877959],
- "red5.png" : ["bitmap-64bitMD5", 2181381724594493116],
+ "tiled-images": [{
+ "checksumAlgorithm" : "bitmap-64bitMD5",
+ "checksumValue" : 5815827069051002745,
+ "comparisonResult" : "no-comparison",
+ "filepath" : "red_skp/bitmap-64bitMD5_5815827069051002745.png",
+ }, {
+ "checksumAlgorithm" : "bitmap-64bitMD5",
+ "checksumValue" : 9323613075234140270,
+ "comparisonResult" : "no-comparison",
+ "filepath" : "red_skp/bitmap-64bitMD5_9323613075234140270.png",
+ }, {
+ "checksumAlgorithm" : "bitmap-64bitMD5",
+ "checksumValue" : 16670399404877552232,
+ "comparisonResult" : "no-comparison",
+ "filepath" : "red_skp/bitmap-64bitMD5_16670399404877552232.png",
+ }, {
+ "checksumAlgorithm" : "bitmap-64bitMD5",
+ "checksumValue" : 2507897274083364964,
+ "comparisonResult" : "no-comparison",
+ "filepath" : "red_skp/bitmap-64bitMD5_2507897274083364964.png",
+ }, {
+ "checksumAlgorithm" : "bitmap-64bitMD5",
+ "checksumValue" : 7325267995523877959,
+ "comparisonResult" : "no-comparison",
+ "filepath" : "red_skp/bitmap-64bitMD5_7325267995523877959.png",
+ }, {
+ "checksumAlgorithm" : "bitmap-64bitMD5",
+ "checksumValue" : 2181381724594493116,
+ "comparisonResult" : "no-comparison",
+ "filepath" : "red_skp/bitmap-64bitMD5_2181381724594493116.png",
+ }],
+ },
+ "green.skp": {
# Manually verified these 6 images, all 256x256 tiles,
# consistent with a tiled version of the 640x400 green rect
# with black borders.
- "green0.png" : ["bitmap-64bitMD5", 12587324416545178013],
- "green1.png" : ["bitmap-64bitMD5", 7624374914829746293],
- "green2.png" : ["bitmap-64bitMD5", 5686489729535631913],
- "green3.png" : ["bitmap-64bitMD5", 7980646035555096146],
- "green4.png" : ["bitmap-64bitMD5", 17817086664365875131],
- "green5.png" : ["bitmap-64bitMD5", 10673669813016809363],
+ "tiled-images": [{
+ "checksumAlgorithm" : "bitmap-64bitMD5",
+ "checksumValue" : 12587324416545178013,
+ "comparisonResult" : "no-comparison",
+ "filepath" : "green_skp/bitmap-64bitMD5_12587324416545178013.png",
+ }, {
+ "checksumAlgorithm" : "bitmap-64bitMD5",
+ "checksumValue" : 7624374914829746293,
+ "comparisonResult" : "no-comparison",
+ "filepath" : "green_skp/bitmap-64bitMD5_7624374914829746293.png",
+ }, {
+ "checksumAlgorithm" : "bitmap-64bitMD5",
+ "checksumValue" : 5686489729535631913,
+ "comparisonResult" : "no-comparison",
+ "filepath" : "green_skp/bitmap-64bitMD5_5686489729535631913.png",
+ }, {
+ "checksumAlgorithm" : "bitmap-64bitMD5",
+ "checksumValue" : 7980646035555096146,
+ "comparisonResult" : "no-comparison",
+ "filepath" : "green_skp/bitmap-64bitMD5_7980646035555096146.png",
+ }, {
+ "checksumAlgorithm" : "bitmap-64bitMD5",
+ "checksumValue" : 17817086664365875131,
+ "comparisonResult" : "no-comparison",
+ "filepath" : "green_skp/bitmap-64bitMD5_17817086664365875131.png",
+ }, {
+ "checksumAlgorithm" : "bitmap-64bitMD5",
+ "checksumValue" : 10673669813016809363,
+ "comparisonResult" : "no-comparison",
+ "filepath" : "green_skp/bitmap-64bitMD5_10673669813016809363.png",
+ }],
}
}
}
self._assert_json_contents(output_json_path, expected_summary_dict)
+ self._assert_directory_contents(self._temp_dir, [
+ 'red_skp', 'green_skp', 'output.json'])
self._assert_directory_contents(
- self._temp_dir,
+ os.path.join(self._temp_dir, 'red_skp'),
['bitmap-64bitMD5_5815827069051002745.png',
'bitmap-64bitMD5_9323613075234140270.png',
'bitmap-64bitMD5_16670399404877552232.png',
'bitmap-64bitMD5_2507897274083364964.png',
'bitmap-64bitMD5_7325267995523877959.png',
- 'bitmap-64bitMD5_2181381724594493116.png',
- 'bitmap-64bitMD5_12587324416545178013.png',
+ 'bitmap-64bitMD5_2181381724594493116.png'])
+ self._assert_directory_contents(
+ os.path.join(self._temp_dir, 'green_skp'),
+ ['bitmap-64bitMD5_12587324416545178013.png',
'bitmap-64bitMD5_7624374914829746293.png',
'bitmap-64bitMD5_5686489729535631913.png',
'bitmap-64bitMD5_7980646035555096146.png',
'bitmap-64bitMD5_17817086664365875131.png',
- 'bitmap-64bitMD5_10673669813016809363.png',
- 'output.json'])
+ 'bitmap-64bitMD5_10673669813016809363.png'])
def _run_render_pictures(self, args):
binary = self.find_path_to_program('render_pictures')