Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 /* | 1 /* |
| 2 * Copyright 2013 Google Inc. | 2 * Copyright 2013 Google Inc. |
| 3 * | 3 * |
| 4 * Use of this source code is governed by a BSD-style license that can be | 4 * Use of this source code is governed by a BSD-style license that can be |
| 5 * found in the LICENSE file. | 5 * found in the LICENSE file. |
| 6 */ | 6 */ |
| 7 | 7 |
| 8 #include "gm_expectations.h" | 8 #include "gm_expectations.h" |
| 9 #include "SkBitmapHasher.h" | 9 #include "SkBitmapHasher.h" |
| 10 #include "SkImageDecoder.h" | 10 #include "SkImageDecoder.h" |
| (...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 158 | 158 |
| 159 | 159 |
| 160 // JsonExpectationsSource class... | 160 // JsonExpectationsSource class... |
| 161 | 161 |
| 162 JsonExpectationsSource::JsonExpectationsSource(const char *jsonPath) { | 162 JsonExpectationsSource::JsonExpectationsSource(const char *jsonPath) { |
| 163 parse(jsonPath, &fJsonRoot); | 163 parse(jsonPath, &fJsonRoot); |
| 164 fJsonExpectedResults = fJsonRoot[kJsonKey_ExpectedResults]; | 164 fJsonExpectedResults = fJsonRoot[kJsonKey_ExpectedResults]; |
| 165 } | 165 } |
| 166 | 166 |
| 167 Expectations JsonExpectationsSource::get(const char *testName) { | 167 Expectations JsonExpectationsSource::get(const char *testName) { |
| 168 return Expectations(fJsonExpectedResults[testName]); | 168 SkString testNameWithExtension(testName); |
| 169 testNameWithExtension.append(".png"); | |
|
epoger
2013/05/08 19:45:08
Patchset 2 adds ".png" extension to the lines in t
| |
| 170 return Expectations(fJsonExpectedResults[testNameWithExtension.c_str()]) ; | |
| 169 } | 171 } |
| 170 | 172 |
| 171 /*static*/ SkData* JsonExpectationsSource::readIntoSkData(SkStream &stream, size_t maxBytes) { | 173 /*static*/ SkData* JsonExpectationsSource::readIntoSkData(SkStream &stream, size_t maxBytes) { |
| 172 if (0 == maxBytes) { | 174 if (0 == maxBytes) { |
| 173 return SkData::NewEmpty(); | 175 return SkData::NewEmpty(); |
| 174 } | 176 } |
| 175 char* bufStart = reinterpret_cast<char *>(sk_malloc_throw(maxBytes)); | 177 char* bufStart = reinterpret_cast<char *>(sk_malloc_throw(maxBytes)); |
| 176 char* bufPtr = bufStart; | 178 char* bufPtr = bufStart; |
| 177 size_t bytesRemaining = maxBytes; | 179 size_t bytesRemaining = maxBytes; |
| 178 while (bytesRemaining > 0) { | 180 while (bytesRemaining > 0) { |
| (...skipping 27 matching lines...) Expand all Loading... | |
| 206 Json::Reader reader; | 208 Json::Reader reader; |
| 207 if (!reader.parse(bytes, bytes+size, *jsonRoot)) { | 209 if (!reader.parse(bytes, bytes+size, *jsonRoot)) { |
| 208 gm_fprintf(stderr, "error parsing JSON file %s\n", jsonPath); | 210 gm_fprintf(stderr, "error parsing JSON file %s\n", jsonPath); |
| 209 DEBUGFAIL_SEE_STDERR; | 211 DEBUGFAIL_SEE_STDERR; |
| 210 return false; | 212 return false; |
| 211 } | 213 } |
| 212 return true; | 214 return true; |
| 213 } | 215 } |
| 214 | 216 |
| 215 } | 217 } |
| OLD | NEW |