120c99993e
ifdef out code that won't build where we don't have jsoncpp. Include ctype instead of string.h for tolower. Depends on https://codereview.chromium.org/282053002/ BUG=skia:2447 R=mtklein@google.com Author: scroggo@google.com Review URL: https://codereview.chromium.org/290603002 git-svn-id: http://skia.googlecode.com/svn/trunk@14768 2bbb7eff-a529-9590-31e7-b0007b416f81
49 lines
1.3 KiB
C++
49 lines
1.3 KiB
C++
#ifndef DMExpectations_DEFINED
|
|
#define DMExpectations_DEFINED
|
|
|
|
#include "DMTask.h"
|
|
#include "gm_expectations.h"
|
|
|
|
namespace DM {
|
|
|
|
struct Expectations {
|
|
virtual ~Expectations() {}
|
|
|
|
// Return true if bitmap is the correct output for task, else false.
|
|
virtual bool check(const Task& task, SkBitmap bitmap) const = 0;
|
|
};
|
|
|
|
class NoExpectations : public Expectations {
|
|
public:
|
|
NoExpectations() {}
|
|
bool check(const Task&, SkBitmap) const SK_OVERRIDE { return true; }
|
|
};
|
|
|
|
#ifdef SK_BUILD_JSON_WRITER
|
|
class JsonExpectations : public Expectations {
|
|
public:
|
|
explicit JsonExpectations(const char* path) : fGMExpectations(path) {}
|
|
|
|
bool check(const Task& task, SkBitmap bitmap) const SK_OVERRIDE {
|
|
SkString filename = task.name();
|
|
filename.append(".png");
|
|
const skiagm::Expectations expectations = fGMExpectations.get(filename.c_str());
|
|
|
|
if (expectations.ignoreFailure() || expectations.empty()) {
|
|
return true;
|
|
}
|
|
|
|
// Delay this calculation as long as possible. It's expensive.
|
|
const skiagm::GmResultDigest digest(bitmap);
|
|
return expectations.match(digest);
|
|
}
|
|
|
|
private:
|
|
skiagm::JsonExpectationsSource fGMExpectations;
|
|
};
|
|
#endif
|
|
|
|
} // namespace DM
|
|
|
|
#endif // DMExpectations_DEFINED
|