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

Unified Diff: gm/gm_error.h

Issue 14187007: GM: allow caller to specify which result types trigger an error (Closed) Base URL: http://skia.googlecode.com/svn/trunk/
Patch Set: Created 7 years, 8 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 | « no previous file | gm/gmmain.cpp » ('j') | gm/gmmain.cpp » ('J')
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: gm/gm_error.h
===================================================================
--- gm/gm_error.h (revision 8622)
+++ gm/gm_error.h (working copy)
@@ -58,6 +58,42 @@
}
/**
+ * Fills in "type" with the ErrorType associated with name "name".
+ * Returns true if we found one, false if it is an unknown type name.
+ */
+ static bool getErrorTypeByName(const char name[], ErrorType *type) {
+ // TODO(epoger): how can we make sure this method stays in sync with the
+ // complete list of ErrorTypes? Unlike getErrorTypeName(), in this case
+ // we don't have the compiler warning about missing enum values to keep
+ // us in sync...
+ if (0 == strcmp(name, "NoGpuContext")) {
borenet 2013/04/12 00:29:45 Suggest making these strings constant and using th
epoger 2013/04/12 02:44:43 Hey, I came up with an elegant, robust (IMHO) appr
borenet 2013/04/12 11:55:37 I like it!
+ *type = kNoGpuContext_ErrorType;
+ return true;
+ }
+ if (0 == strcmp(name, "IntentionallySkipped")) {
+ *type = kIntentionallySkipped_ErrorType;
+ return true;
+ }
+ if (0 == strcmp(name, "RenderModeMismatch")) {
+ *type = kRenderModeMismatch_ErrorType;
+ return true;
+ }
+ if (0 == strcmp(name, "ExpectationsMismatch")) {
+ *type = kExpectationsMismatch_ErrorType;
+ return true;
+ }
+ if (0 == strcmp(name, "MissingExpectations")) {
+ *type = kMissingExpectations_ErrorType;
+ return true;
+ }
+ if (0 == strcmp(name, "WritingReferenceImage")) {
+ *type = kWritingReferenceImage_ErrorType;
+ return true;
+ }
+ return false;
+ }
+
+ /**
* A combination of 0 or more ErrorTypes.
*/
class ErrorCombination {
@@ -94,6 +130,27 @@
}
/**
+ * Returns a string representation of all ErrorTypes in this
+ * ErrorCombination.
+ *
+ * @param separator text with which to separate ErrorType names
+ */
+ SkString asString(const char separator[]) const {
+ SkString s;
+ int howMany = 0;
+ for (int typeInt = 0; typeInt <= kLast_ErrorType; typeInt++) {
+ ErrorType type = static_cast<ErrorType>(typeInt);
+ if (this->includes(type)) {
+ if (0 < howMany++) {
borenet 2013/04/12 00:29:45 Is this significantly faster than (s.size() == 0)?
epoger 2013/04/12 02:44:43 Probably not. Now calling s.isEmpty()... thanks f
+ s.append(separator);
+ }
+ s.append(getErrorTypeName(type));
+ }
+ }
+ return s;
+ }
+
+ /**
* Returns a new ErrorCombination, which includes the union of all
* ErrorTypes in two ErrorCombination objects (this and other).
*/
« no previous file with comments | « no previous file | gm/gmmain.cpp » ('j') | gm/gmmain.cpp » ('J')

Powered by Google App Engine
This is Rietveld 408576698