GM: stop recording all *_pdf.png results as "INVALID" on non-Mac platforms
BUG=https://code.google.com/p/skia/issues/detail?id=1352
R=edisonn@google.com
Review URL: https://codereview.chromium.org/17366003
git-svn-id: http://skia.googlecode.com/svn/trunk@9912 2bbb7eff-a529-9590-31e7-b0007b416f81
diff --git a/gm/gmmain.cpp b/gm/gmmain.cpp
index 8c015e7..ab8053e 100644
--- a/gm/gmmain.cpp
+++ b/gm/gmmain.cpp
@@ -664,7 +664,7 @@
ErrorCombination write_reference_image(const ConfigData& gRec, const char writePath [],
const char renderModeDescriptor [],
const char *shortName,
- const BitmapAndDigest& bitmapAndDigest,
+ const BitmapAndDigest* bitmapAndDigest,
SkDynamicMemoryWStream* document) {
SkString path;
bool success = false;
@@ -673,8 +673,8 @@
(gRec.fBackend == kPDF_Backend && CAN_IMAGE_PDF)) {
path = make_bitmap_filename(writePath, shortName, gRec.fName, renderModeDescriptor,
- bitmapAndDigest.fDigest);
- success = write_bitmap(path, bitmapAndDigest.fBitmap);
+ bitmapAndDigest->fDigest);
+ success = write_bitmap(path, bitmapAndDigest->fBitmap);
}
if (kPDF_Backend == gRec.fBackend) {
path = make_filename(writePath, shortName, gRec.fName, renderModeDescriptor,
@@ -905,47 +905,56 @@
* @param gRec
* @param writePath unless this is NULL, write out actual images into this
* directory
- * @param actualBitmap bitmap generated by this run
- * @param pdf
+ * @param actualBitmapAndDigest ptr to bitmap generated by this run, or NULL
+ * if we don't have a usable bitmap representation
+ * @param document pdf or xps representation, if appropriate
*/
ErrorCombination compare_test_results_to_stored_expectations(
GM* gm, const ConfigData& gRec, const char writePath[],
- SkBitmap& actualBitmap, SkDynamicMemoryWStream* pdf) {
+ const BitmapAndDigest* actualBitmapAndDigest, SkDynamicMemoryWStream* document) {
- BitmapAndDigest actualBitmapAndDigest(actualBitmap);
SkString shortNamePlusConfig = make_shortname_plus_config(gm->shortName(), gRec.fName);
SkString nameWithExtension(shortNamePlusConfig);
nameWithExtension.append(".");
nameWithExtension.append(kPNG_FileExtension);
ErrorCombination errors;
- ExpectationsSource *expectationsSource = this->fExpectationsSource.get();
- if (expectationsSource && (gRec.fFlags & kRead_ConfigFlag)) {
- /*
- * Get the expected results for this test, as one or more allowed
- * hash digests. The current implementation of expectationsSource
- * get this by computing the hash digest of a single PNG file on disk.
- *
- * TODO(epoger): This relies on the fact that
- * force_all_opaque() was called on the bitmap before it
- * was written to disk as a PNG in the first place. If
- * not, the hash digest returned here may not match the
- * hash digest of actualBitmap, which *has* been run through
- * force_all_opaque().
- * See comments above complete_bitmap() for more detail.
- */
- Expectations expectations = expectationsSource->get(nameWithExtension.c_str());
- errors.add(compare_to_expectations(expectations, actualBitmapAndDigest,
- gm->shortName(), gRec.fName, "", true));
- } else {
- // If we are running without expectations, we still want to
- // record the actual results.
- add_actual_results_to_json_summary(nameWithExtension.c_str(),
- actualBitmapAndDigest.fDigest,
- ErrorCombination(kMissingExpectations_ErrorType),
- false);
- RecordTestResults(ErrorCombination(kMissingExpectations_ErrorType),
+
+ if (NULL == actualBitmapAndDigest) {
+ // Note that we intentionally skipped validating the results for
+ // this test, because we don't know how to generate an SkBitmap
+ // version of the output.
+ RecordTestResults(ErrorCombination(kIntentionallySkipped_ErrorType),
shortNamePlusConfig, "");
+ } else {
+ ExpectationsSource *expectationsSource = this->fExpectationsSource.get();
+ if (expectationsSource && (gRec.fFlags & kRead_ConfigFlag)) {
+ /*
+ * Get the expected results for this test, as one or more allowed
+ * hash digests. The current implementation of expectationsSource
+ * get this by computing the hash digest of a single PNG file on disk.
+ *
+ * TODO(epoger): This relies on the fact that
+ * force_all_opaque() was called on the bitmap before it
+ * was written to disk as a PNG in the first place. If
+ * not, the hash digest returned here may not match the
+ * hash digest of actualBitmap, which *has* been run through
+ * force_all_opaque().
+ * See comments above complete_bitmap() for more detail.
+ */
+ Expectations expectations = expectationsSource->get(nameWithExtension.c_str());
+ errors.add(compare_to_expectations(expectations, *actualBitmapAndDigest,
+ gm->shortName(), gRec.fName, "", true));
+ } else {
+ // If we are running without expectations, we still want to
+ // record the actual results.
+ add_actual_results_to_json_summary(nameWithExtension.c_str(),
+ actualBitmapAndDigest->fDigest,
+ ErrorCombination(kMissingExpectations_ErrorType),
+ false);
+ RecordTestResults(ErrorCombination(kMissingExpectations_ErrorType),
+ shortNamePlusConfig, "");
+ }
}
// TODO: Consider moving this into compare_to_expectations(),
@@ -954,7 +963,7 @@
// renderModes of all tests! That would be a lot of files.
if (writePath && (gRec.fFlags & kWrite_ConfigFlag)) {
errors.add(write_reference_image(gRec, writePath, "", gm->shortName(),
- actualBitmapAndDigest, pdf));
+ actualBitmapAndDigest, document));
}
return errors;
@@ -1054,12 +1063,22 @@
SkAutoDataUnref data(document.copyToData());
SkMemoryStream stream(data->data(), data->size());
SkPDFDocumentToBitmap(&stream, bitmap);
+#else
+ bitmap = NULL; // we don't generate a bitmap rendering of the PDF file
#endif
} else if (gRec.fBackend == kXPS_Backend) {
generate_xps(gm, document);
+ bitmap = NULL; // we don't generate a bitmap rendering of the XPS file
}
- return compare_test_results_to_stored_expectations(
- gm, gRec, writePath, *bitmap, &document);
+
+ if (NULL == bitmap) {
+ return compare_test_results_to_stored_expectations(
+ gm, gRec, writePath, NULL, &document);
+ } else {
+ BitmapAndDigest bitmapAndDigest(*bitmap);
+ return compare_test_results_to_stored_expectations(
+ gm, gRec, writePath, &bitmapAndDigest, &document);
+ }
}
ErrorCombination test_deferred_drawing(GM* gm,
diff --git a/gm/tests/outputs/add-config-pdf/output-expected/command_line b/gm/tests/outputs/add-config-pdf/output-expected/command_line
new file mode 100644
index 0000000..611f036
--- /dev/null
+++ b/gm/tests/outputs/add-config-pdf/output-expected/command_line
@@ -0,0 +1 @@
+out/Debug/gm --verbose --hierarchy --match selftest1 --config 8888 565 pdf -r gm/tests/inputs/json/identical-bytes.json --writeJsonSummaryPath gm/tests/outputs/add-config-pdf/output-actual/json-summary.txt --writePath gm/tests/outputs/add-config-pdf/output-actual/writePath --mismatchPath gm/tests/outputs/add-config-pdf/output-actual/mismatchPath --missingExpectationsPath gm/tests/outputs/add-config-pdf/output-actual/missingExpectationsPath
diff --git a/gm/tests/outputs/add-config-pdf/output-expected/json-summary.txt b/gm/tests/outputs/add-config-pdf/output-expected/json-summary.txt
new file mode 100644
index 0000000..fad1ffe
--- /dev/null
+++ b/gm/tests/outputs/add-config-pdf/output-expected/json-summary.txt
@@ -0,0 +1,25 @@
+{
+ "actual-results" : {
+ "failed" : null,
+ "failure-ignored" : null,
+ "no-comparison" : null,
+ "succeeded" : {
+ "565/selftest1.png" : [ "bitmap-64bitMD5", 12927999507540085554 ],
+ "8888/selftest1.png" : [ "bitmap-64bitMD5", 1209453360120438698 ]
+ }
+ },
+ "expected-results" : {
+ "565/selftest1.png" : {
+ "allowed-digests" : [
+ [ "bitmap-64bitMD5", 12927999507540085554 ]
+ ],
+ "ignore-failure" : false
+ },
+ "8888/selftest1.png" : {
+ "allowed-digests" : [
+ [ "bitmap-64bitMD5", 1209453360120438698 ]
+ ],
+ "ignore-failure" : false
+ }
+ }
+}
diff --git a/gm/tests/outputs/add-config-pdf/output-expected/mismatchPath/565/bogusfile b/gm/tests/outputs/add-config-pdf/output-expected/mismatchPath/565/bogusfile
new file mode 100644
index 0000000..d86cd5b
--- /dev/null
+++ b/gm/tests/outputs/add-config-pdf/output-expected/mismatchPath/565/bogusfile
@@ -0,0 +1 @@
+Created additional file to make sure directory isn't empty, because self-test cannot handle empty directories.
diff --git a/gm/tests/outputs/add-config-pdf/output-expected/mismatchPath/8888/bogusfile b/gm/tests/outputs/add-config-pdf/output-expected/mismatchPath/8888/bogusfile
new file mode 100644
index 0000000..d86cd5b
--- /dev/null
+++ b/gm/tests/outputs/add-config-pdf/output-expected/mismatchPath/8888/bogusfile
@@ -0,0 +1 @@
+Created additional file to make sure directory isn't empty, because self-test cannot handle empty directories.
diff --git a/gm/tests/outputs/add-config-pdf/output-expected/mismatchPath/bogusfile b/gm/tests/outputs/add-config-pdf/output-expected/mismatchPath/bogusfile
new file mode 100644
index 0000000..d86cd5b
--- /dev/null
+++ b/gm/tests/outputs/add-config-pdf/output-expected/mismatchPath/bogusfile
@@ -0,0 +1 @@
+Created additional file to make sure directory isn't empty, because self-test cannot handle empty directories.
diff --git a/gm/tests/outputs/add-config-pdf/output-expected/mismatchPath/pdf/bogusfile b/gm/tests/outputs/add-config-pdf/output-expected/mismatchPath/pdf/bogusfile
new file mode 100644
index 0000000..d86cd5b
--- /dev/null
+++ b/gm/tests/outputs/add-config-pdf/output-expected/mismatchPath/pdf/bogusfile
@@ -0,0 +1 @@
+Created additional file to make sure directory isn't empty, because self-test cannot handle empty directories.
diff --git a/gm/tests/outputs/add-config-pdf/output-expected/missingExpectationsPath/565/bogusfile b/gm/tests/outputs/add-config-pdf/output-expected/missingExpectationsPath/565/bogusfile
new file mode 100644
index 0000000..d86cd5b
--- /dev/null
+++ b/gm/tests/outputs/add-config-pdf/output-expected/missingExpectationsPath/565/bogusfile
@@ -0,0 +1 @@
+Created additional file to make sure directory isn't empty, because self-test cannot handle empty directories.
diff --git a/gm/tests/outputs/add-config-pdf/output-expected/missingExpectationsPath/8888/bogusfile b/gm/tests/outputs/add-config-pdf/output-expected/missingExpectationsPath/8888/bogusfile
new file mode 100644
index 0000000..d86cd5b
--- /dev/null
+++ b/gm/tests/outputs/add-config-pdf/output-expected/missingExpectationsPath/8888/bogusfile
@@ -0,0 +1 @@
+Created additional file to make sure directory isn't empty, because self-test cannot handle empty directories.
diff --git a/gm/tests/outputs/add-config-pdf/output-expected/missingExpectationsPath/bogusfile b/gm/tests/outputs/add-config-pdf/output-expected/missingExpectationsPath/bogusfile
new file mode 100644
index 0000000..d86cd5b
--- /dev/null
+++ b/gm/tests/outputs/add-config-pdf/output-expected/missingExpectationsPath/bogusfile
@@ -0,0 +1 @@
+Created additional file to make sure directory isn't empty, because self-test cannot handle empty directories.
diff --git a/gm/tests/outputs/add-config-pdf/output-expected/missingExpectationsPath/pdf/bogusfile b/gm/tests/outputs/add-config-pdf/output-expected/missingExpectationsPath/pdf/bogusfile
new file mode 100644
index 0000000..d86cd5b
--- /dev/null
+++ b/gm/tests/outputs/add-config-pdf/output-expected/missingExpectationsPath/pdf/bogusfile
@@ -0,0 +1 @@
+Created additional file to make sure directory isn't empty, because self-test cannot handle empty directories.
diff --git a/gm/tests/outputs/add-config-pdf/output-expected/return_value b/gm/tests/outputs/add-config-pdf/output-expected/return_value
new file mode 100644
index 0000000..573541a
--- /dev/null
+++ b/gm/tests/outputs/add-config-pdf/output-expected/return_value
@@ -0,0 +1 @@
+0
diff --git a/gm/tests/outputs/add-config-pdf/output-expected/stderr b/gm/tests/outputs/add-config-pdf/output-expected/stderr
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/gm/tests/outputs/add-config-pdf/output-expected/stderr
diff --git a/gm/tests/outputs/add-config-pdf/output-expected/stdout b/gm/tests/outputs/add-config-pdf/output-expected/stdout
new file mode 100644
index 0000000..4052bbf
--- /dev/null
+++ b/gm/tests/outputs/add-config-pdf/output-expected/stdout
@@ -0,0 +1,18 @@
+GM: These configs will be run: 8888 565 pdf
+GM: reading expectations from JSON summary file gm/tests/inputs/json/identical-bytes.json
+GM: writing to gm/tests/outputs/add-config-pdf/output-actual/writePath
+GM: writing mismatches to gm/tests/outputs/add-config-pdf/output-actual/mismatchPath
+GM: writing images without expectations to gm/tests/outputs/add-config-pdf/output-actual/missingExpectationsPath
+GM: drawing... selftest1 [300 200]
+GM: Ran 1 GMs
+GM: ... over 3 configs ["8888", "565", "pdf"]
+GM: ... and 7 modes ["pipe", "pipe cross-process", "pipe cross-process, shared address", "replay", "rtree", "serialize", "tilegrid"]
+GM: ... so there should be a total of 10 tests.
+GM: Ran 10 tests: NoGpuContext=0 IntentionallySkipped=1 RenderModeMismatch=0 ExpectationsMismatch=0 MissingExpectations=0 WritingReferenceImage=0
+GM: [*] 0 NoGpuContext:
+GM: [ ] 1 IntentionallySkipped: pdf/selftest1
+GM: [*] 0 RenderModeMismatch:
+GM: [*] 0 ExpectationsMismatch:
+GM: [ ] 0 MissingExpectations:
+GM: [*] 0 WritingReferenceImage:
+GM: (results marked with [*] will cause nonzero return value)
diff --git a/gm/tests/outputs/add-config-pdf/output-expected/writePath/565/bogusfile b/gm/tests/outputs/add-config-pdf/output-expected/writePath/565/bogusfile
new file mode 100644
index 0000000..d86cd5b
--- /dev/null
+++ b/gm/tests/outputs/add-config-pdf/output-expected/writePath/565/bogusfile
@@ -0,0 +1 @@
+Created additional file to make sure directory isn't empty, because self-test cannot handle empty directories.
diff --git a/gm/tests/outputs/add-config-pdf/output-expected/writePath/565/selftest1.png b/gm/tests/outputs/add-config-pdf/output-expected/writePath/565/selftest1.png
new file mode 100644
index 0000000..57ced63
--- /dev/null
+++ b/gm/tests/outputs/add-config-pdf/output-expected/writePath/565/selftest1.png
@@ -0,0 +1 @@
+[contents of gm/tests/outputs/add-config-pdf/output-actual/writePath/565/selftest1.png]
diff --git a/gm/tests/outputs/add-config-pdf/output-expected/writePath/8888/bogusfile b/gm/tests/outputs/add-config-pdf/output-expected/writePath/8888/bogusfile
new file mode 100644
index 0000000..d86cd5b
--- /dev/null
+++ b/gm/tests/outputs/add-config-pdf/output-expected/writePath/8888/bogusfile
@@ -0,0 +1 @@
+Created additional file to make sure directory isn't empty, because self-test cannot handle empty directories.
diff --git a/gm/tests/outputs/add-config-pdf/output-expected/writePath/8888/selftest1.png b/gm/tests/outputs/add-config-pdf/output-expected/writePath/8888/selftest1.png
new file mode 100644
index 0000000..da67a30
--- /dev/null
+++ b/gm/tests/outputs/add-config-pdf/output-expected/writePath/8888/selftest1.png
@@ -0,0 +1 @@
+[contents of gm/tests/outputs/add-config-pdf/output-actual/writePath/8888/selftest1.png]
diff --git a/gm/tests/outputs/add-config-pdf/output-expected/writePath/bogusfile b/gm/tests/outputs/add-config-pdf/output-expected/writePath/bogusfile
new file mode 100644
index 0000000..d86cd5b
--- /dev/null
+++ b/gm/tests/outputs/add-config-pdf/output-expected/writePath/bogusfile
@@ -0,0 +1 @@
+Created additional file to make sure directory isn't empty, because self-test cannot handle empty directories.
diff --git a/gm/tests/outputs/add-config-pdf/output-expected/writePath/pdf/bogusfile b/gm/tests/outputs/add-config-pdf/output-expected/writePath/pdf/bogusfile
new file mode 100644
index 0000000..d86cd5b
--- /dev/null
+++ b/gm/tests/outputs/add-config-pdf/output-expected/writePath/pdf/bogusfile
@@ -0,0 +1 @@
+Created additional file to make sure directory isn't empty, because self-test cannot handle empty directories.
diff --git a/gm/tests/outputs/add-config-pdf/output-expected/writePath/pdf/selftest1.pdf b/gm/tests/outputs/add-config-pdf/output-expected/writePath/pdf/selftest1.pdf
new file mode 100644
index 0000000..acca03b
--- /dev/null
+++ b/gm/tests/outputs/add-config-pdf/output-expected/writePath/pdf/selftest1.pdf
@@ -0,0 +1 @@
+[contents of gm/tests/outputs/add-config-pdf/output-actual/writePath/pdf/selftest1.pdf]
diff --git a/gm/tests/run.sh b/gm/tests/run.sh
index ef36680..cf1b814 100755
--- a/gm/tests/run.sh
+++ b/gm/tests/run.sh
@@ -108,6 +108,9 @@
for IMAGEFILE in $(find $ACTUAL_OUTPUT_DIR -name *.png); do
echo "[contents of $IMAGEFILE]" >$IMAGEFILE
done
+ for IMAGEFILE in $(find $ACTUAL_OUTPUT_DIR -name *.pdf); do
+ echo "[contents of $IMAGEFILE]" >$IMAGEFILE
+ done
# Add a file to any empty subdirectories.
for DIR in $(find $ACTUAL_OUTPUT_DIR -mindepth 1 -type d); do
@@ -199,6 +202,9 @@
# Compare generated image against an empty "expected image" dir, but NOT in verbose mode.
gm_test "--hierarchy --match selftest1 $CONFIGS -r $GM_INPUTS/images/empty-dir" "$GM_OUTPUTS/nonverbose"
+# Add pdf to the list of configs.
+gm_test "--verbose --hierarchy --match selftest1 $CONFIGS pdf -r $GM_INPUTS/json/identical-bytes.json" "$GM_OUTPUTS/add-config-pdf"
+
# If run without "-r", the JSON's "actual-results" section should contain
# actual checksums marked as "failure-ignored", but the "expected-results"
# section should be empty.