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

Side by Side Diff: gm/gm_expectations.h

Issue 14670021: Write/compare against expectations in skimage tool. (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: Instead of appending a string of potentially infinite length, append a single character. Created 7 years, 7 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | gm/gm_expectations.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 #ifndef gm_expectations_DEFINED 7 #ifndef gm_expectations_DEFINED
8 #define gm_expectations_DEFINED 8 #define gm_expectations_DEFINED
9 9
10 #include "gm.h" 10 #include "gm.h"
(...skipping 21 matching lines...) Expand all
32 32
33 // The actual type we use to represent a checksum is hidden in here. 33 // The actual type we use to represent a checksum is hidden in here.
34 typedef Json::UInt64 Checksum; 34 typedef Json::UInt64 Checksum;
35 static inline Json::Value asJsonValue(Checksum checksum) { 35 static inline Json::Value asJsonValue(Checksum checksum) {
36 return checksum; 36 return checksum;
37 } 37 }
38 static inline Checksum asChecksum(Json::Value jsonValue) { 38 static inline Checksum asChecksum(Json::Value jsonValue) {
39 return jsonValue.asUInt64(); 39 return jsonValue.asUInt64();
40 } 40 }
41 41
42 static void gm_fprintf(FILE *stream, const char format[], ...) { 42 void gm_fprintf(FILE *stream, const char format[], ...);
43 va_list args;
44 va_start(args, format);
45 fprintf(stream, "GM: ");
46 vfprintf(stream, format, args);
47 va_end(args);
48 }
49 43
50 static SkString make_filename(const char path[], 44 SkString make_filename(const char path[],
51 const char renderModeDescriptor[], 45 const char renderModeDescriptor[],
52 const char *name, 46 const char *name,
53 const char suffix[]) { 47 const char suffix[]);
54 SkString filename(path);
55 if (filename.endsWith(SkPATH_SEPARATOR)) {
56 filename.remove(filename.size() - 1, 1);
57 }
58 filename.appendf("%c%s%s.%s", SkPATH_SEPARATOR,
59 name, renderModeDescriptor, suffix);
60 return filename;
61 }
62 48
63 Json::Value ActualResultAsJsonValue(const SkHashDigest& result); 49 Json::Value ActualResultAsJsonValue(const SkHashDigest& result);
64 50
65 Json::Value CreateJsonTree(Json::Value expectedResults, 51 Json::Value CreateJsonTree(Json::Value expectedResults,
66 Json::Value actualResultsFailed, 52 Json::Value actualResultsFailed,
67 Json::Value actualResultsFailureIgnored, 53 Json::Value actualResultsFailureIgnored,
68 Json::Value actualResultsNoComparison, 54 Json::Value actualResultsNoComparison,
69 Json::Value actualResultsSucceeded); 55 Json::Value actualResultsSucceeded);
70 56
71 /** 57 /**
(...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after
201 * if (NULL != dataRef.get()) { 187 * if (NULL != dataRef.get()) {
202 * size_t bytesActuallyRead = dataRef.get()->size(); 188 * size_t bytesActuallyRead = dataRef.get()->size();
203 * // use the data... 189 * // use the data...
204 * } 190 * }
205 * } 191 * }
206 * // underlying buffer has been freed, thanks to auto unref 192 * // underlying buffer has been freed, thanks to auto unref
207 * 193 *
208 */ 194 */
209 // TODO(epoger): Move this, into SkStream.[cpp|h] as attempted in 195 // TODO(epoger): Move this, into SkStream.[cpp|h] as attempted in
210 // https://codereview.appspot.com/7300071 ? 196 // https://codereview.appspot.com/7300071 ?
211 // And maybe readFileIntoSkData() also? 197 // And maybe ReadFileIntoSkData() also?
212 static SkData* readIntoSkData(SkStream &stream, size_t maxBytes); 198 static SkData* ReadIntoSkData(SkStream &stream, size_t maxBytes);
213 199
214 /** 200 /**
215 * Wrapper around readIntoSkData for files: reads the entire file into 201 * Wrapper around ReadIntoSkData for files: reads the entire file into
216 * an SkData object. 202 * an SkData object.
217 */ 203 */
218 static SkData* readFileIntoSkData(SkFILEStream &stream) { 204 static SkData* ReadFileIntoSkData(SkFILEStream &stream) {
219 return readIntoSkData(stream, stream.getLength()); 205 return ReadIntoSkData(stream, stream.getLength());
220 } 206 }
221 207
222 /** 208 /**
223 * Read the file contents from jsonPath and parse them into jsonRoot. 209 * Read the file contents from jsonPath and parse them into jsonRoot.
224 * 210 *
225 * Returns true if successful. 211 * Returns true if successful.
226 */ 212 */
227 static bool parse(const char *jsonPath, Json::Value *jsonRoot); 213 static bool Parse(const char *jsonPath, Json::Value *jsonRoot);
228 214
229 Json::Value fJsonRoot; 215 Json::Value fJsonRoot;
230 Json::Value fJsonExpectedResults; 216 Json::Value fJsonExpectedResults;
231 }; 217 };
232 218
233 } 219 }
234 #endif 220 #endif
OLDNEW
« no previous file with comments | « no previous file | gm/gm_expectations.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698