Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(95)

Unified Diff: tools/image_expectations.cpp

Issue 283123002: render_pictures: add --mismatchPath flag (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: fix SkDebuggerGUI Created 6 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « tools/image_expectations.h ('k') | tools/picture_utils.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tools/image_expectations.cpp
diff --git a/tools/image_expectations.cpp b/tools/image_expectations.cpp
index 9b180da5feded20795c7e900a8cd2ff7cf9159c5..24c91755415d62e4e292cbd72d0af0b76f4045cc 100644
--- a/tools/image_expectations.cpp
+++ b/tools/image_expectations.cpp
@@ -104,7 +104,7 @@ namespace sk_tools {
}
void ImageResultsAndExpectations::add(const char *sourceName, const char *fileName,
- const ImageDigest &digest, const int *tileNumber) {
+ const ImageDigest &digest, const int *tileNumber) {
// Get expectation, if any.
Json::Value expectedImage;
if (!fExpectedResults.isNull()) {
@@ -146,6 +146,29 @@ namespace sk_tools {
}
}
+ bool ImageResultsAndExpectations::matchesExpectation(const char *sourceName,
+ const ImageDigest &digest,
+ const int *tileNumber) {
+ if (fExpectedResults.isNull()) {
+ return false;
+ }
+
+ Json::Value expectedImage;
+ if (NULL == tileNumber) {
+ expectedImage = fExpectedResults[sourceName][kJsonKey_Source_WholeImage];
+ } else {
+ expectedImage = fExpectedResults[sourceName][kJsonKey_Source_TiledImages][*tileNumber];
+ }
+ if (expectedImage.isNull()) {
+ return false;
+ }
+
+ Json::Value actualChecksumAlgorithm = digest.getHashType().c_str();
+ Json::Value actualChecksumValue = Json::UInt64(digest.getHashValue());
+ return ((actualChecksumAlgorithm == expectedImage[kJsonKey_Image_ChecksumAlgorithm]) &&
+ (actualChecksumValue == expectedImage[kJsonKey_Image_ChecksumValue]));
+ }
+
void ImageResultsAndExpectations::writeToFile(const char *filename) const {
Json::Value header;
header[kJsonKey_Header_Type] = kJsonValue_Header_Type;
« no previous file with comments | « tools/image_expectations.h ('k') | tools/picture_utils.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698