GM: include filename extension (.png) of each output file in JSON summary
Doing this so that, once we *do* start writing PDF checksums into the JSON
summary, we'll be able to distinguish those from the PNG checksums.
Otherwise, we could have naming collisions.
R=scroggo@google.com
Review URL: https://codereview.chromium.org/14890017
git-svn-id: http://skia.googlecode.com/svn/trunk@9119 2bbb7eff-a529-9590-31e7-b0007b416f81
diff --git a/gm/gm_expectations.cpp b/gm/gm_expectations.cpp
index d9ed779..2c6dede 100644
--- a/gm/gm_expectations.cpp
+++ b/gm/gm_expectations.cpp
@@ -32,17 +32,24 @@
va_end(args);
}
+ SkString SkPathJoin(const char *rootPath, const char *relativePath) {
+ SkString result(rootPath);
+ if (!result.endsWith(SkPATH_SEPARATOR)) {
+ result.appendUnichar(SkPATH_SEPARATOR);
+ }
+ result.append(relativePath);
+ return result;
+ }
+
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;
+ SkString filename(name);
+ filename.append(renderModeDescriptor);
+ filename.appendUnichar('.');
+ filename.append(suffix);
+ return SkPathJoin(path, filename.c_str());
}
// TODO(epoger): This currently assumes that the result SkHashDigest was
@@ -162,8 +169,7 @@
// IndividualImageExpectationsSource class...
Expectations IndividualImageExpectationsSource::get(const char *testName) {
- SkString path = make_filename(fRootDir.c_str(), "", testName,
- "png");
+ SkString path = SkPathJoin(fRootDir.c_str(), testName);
SkBitmap referenceBitmap;
bool decodedReferenceBitmap =
SkImageDecoder::DecodeFile(path.c_str(), &referenceBitmap,