Chromium Code Reviews| 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). |
| */ |