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

Unified Diff: gm/gm_expectations.cpp

Issue 14670021: Write/compare against expectations in skimage tool. (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: Instead of appending a string of potentially infinite length, append a single character. Created 7 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 | « gm/gm_expectations.h ('k') | gyp/gm.gyp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: gm/gm_expectations.cpp
diff --git a/gm/gm_expectations.cpp b/gm/gm_expectations.cpp
index 72fb0e6a8d135f92bc475ca35dd3cd8d8c4d912c..d9ed7798bbc222daf0b357e0992c49ff29d53029 100644
--- a/gm/gm_expectations.cpp
+++ b/gm/gm_expectations.cpp
@@ -24,6 +24,27 @@ const static char kJsonKey_ExpectedResults_IgnoreFailure[] = "ignore-f
namespace skiagm {
+ void gm_fprintf(FILE *stream, const char format[], ...) {
+ va_list args;
+ va_start(args, format);
+ fprintf(stream, "GM: ");
+ vfprintf(stream, format, args);
+ va_end(args);
+ }
+
+ SkString make_filename(const char path[],
+ const char renderModeDescriptor[],
+ const char *name,
+ const char suffix[]) {
+ SkString filename(path);
+ if (filename.endsWith(SkPATH_SEPARATOR)) {
+ filename.remove(filename.size() - 1, 1);
+ }
+ filename.appendf("%c%s%s.%s", SkPATH_SEPARATOR,
+ name, renderModeDescriptor, suffix);
+ return filename;
+ }
+
// TODO(epoger): This currently assumes that the result SkHashDigest was
// generated as an SkHashDigest of an SkBitmap. We'll need to allow for other
// hash types to cover non-bitmaps.
@@ -160,7 +181,7 @@ namespace skiagm {
// JsonExpectationsSource class...
JsonExpectationsSource::JsonExpectationsSource(const char *jsonPath) {
- parse(jsonPath, &fJsonRoot);
+ Parse(jsonPath, &fJsonRoot);
fJsonExpectedResults = fJsonRoot[kJsonKey_ExpectedResults];
}
@@ -168,7 +189,7 @@ namespace skiagm {
return Expectations(fJsonExpectedResults[testName]);
}
- /*static*/ SkData* JsonExpectationsSource::readIntoSkData(SkStream &stream, size_t maxBytes) {
+ /*static*/ SkData* JsonExpectationsSource::ReadIntoSkData(SkStream &stream, size_t maxBytes) {
if (0 == maxBytes) {
return SkData::NewEmpty();
}
@@ -186,7 +207,7 @@ namespace skiagm {
return SkData::NewFromMalloc(bufStart, maxBytes - bytesRemaining);
}
- /*static*/ bool JsonExpectationsSource::parse(const char *jsonPath, Json::Value *jsonRoot) {
+ /*static*/ bool JsonExpectationsSource::Parse(const char *jsonPath, Json::Value *jsonRoot) {
SkFILEStream inFile(jsonPath);
if (!inFile.isValid()) {
gm_fprintf(stderr, "unable to read JSON file %s\n", jsonPath);
@@ -194,7 +215,7 @@ namespace skiagm {
return false;
}
- SkAutoDataUnref dataRef(readFileIntoSkData(inFile));
+ SkAutoDataUnref dataRef(ReadFileIntoSkData(inFile));
if (NULL == dataRef.get()) {
gm_fprintf(stderr, "error reading JSON file %s\n", jsonPath);
DEBUGFAIL_SEE_STDERR;
« no previous file with comments | « gm/gm_expectations.h ('k') | gyp/gm.gyp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698