OLD | NEW |
1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 // This file input format is based loosely on | 5 // This file input format is based loosely on |
6 // WebKitTools/DumpRenderTree/ImageDiff.m | 6 // WebKitTools/DumpRenderTree/ImageDiff.m |
7 | 7 |
8 // The exact format of this tool's output to stdout is important, to match | 8 // The exact format of this tool's output to stdout is important, to match |
9 // what the run-webkit-tests script expects. | 9 // what the run-webkit-tests script expects. |
10 | 10 |
11 #include <algorithm> | 11 #include <algorithm> |
12 #include <vector> | 12 #include <vector> |
13 | 13 |
14 #include "base/basictypes.h" | 14 #include "base/basictypes.h" |
15 #include "base/command_line.h" | 15 #include "base/command_line.h" |
16 #include "base/gfx/png_decoder.h" | 16 #include "base/gfx/png_decoder.h" |
17 #include "base/logging.h" | 17 #include "base/logging.h" |
| 18 #include "base/process_util.h" |
18 #include "base/scoped_ptr.h" | 19 #include "base/scoped_ptr.h" |
19 | 20 |
20 // Causes the app to remain open, waiting for pairs of filenames on stdin. | 21 // Causes the app to remain open, waiting for pairs of filenames on stdin. |
21 // The caller is then responsible for terminating this app. | 22 // The caller is then responsible for terminating this app. |
22 static const wchar_t kOptionPollStdin[] = L"use-stdin"; | 23 static const wchar_t kOptionPollStdin[] = L"use-stdin"; |
23 | 24 |
24 // Return codes used by this utility. | 25 // Return codes used by this utility. |
25 static const int kStatusSame = 0; | 26 static const int kStatusSame = 0; |
26 static const int kStatusDifferent = 1; | 27 static const int kStatusDifferent = 1; |
27 static const int kStatusError = 2; | 28 static const int kStatusError = 2; |
(...skipping 193 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
221 actual_image.Clear(); | 222 actual_image.Clear(); |
222 baseline_image.Clear(); | 223 baseline_image.Clear(); |
223 } | 224 } |
224 | 225 |
225 fflush(stdout); | 226 fflush(stdout); |
226 } | 227 } |
227 */ | 228 */ |
228 } | 229 } |
229 | 230 |
230 int main(int argc, const char* argv[]) { | 231 int main(int argc, const char* argv[]) { |
| 232 process_util::EnableTerminationOnHeapCorruption(); |
231 CommandLine parsed_command_line; | 233 CommandLine parsed_command_line; |
232 if (parsed_command_line.HasSwitch(kOptionPollStdin)) { | 234 if (parsed_command_line.HasSwitch(kOptionPollStdin)) { |
233 // Watch stdin for filenames. | 235 // Watch stdin for filenames. |
234 char stdin_buffer[2048]; | 236 char stdin_buffer[2048]; |
235 char filename1_buffer[2048]; | 237 char filename1_buffer[2048]; |
236 bool have_filename1 = false; | 238 bool have_filename1 = false; |
237 while (fgets(stdin_buffer, sizeof(stdin_buffer), stdin)) { | 239 while (fgets(stdin_buffer, sizeof(stdin_buffer), stdin)) { |
238 char *newLine = strchr(stdin_buffer, '\n'); | 240 char *newLine = strchr(stdin_buffer, '\n'); |
239 if (newLine) | 241 if (newLine) |
240 *newLine = '\0'; | 242 *newLine = '\0'; |
(...skipping 17 matching lines...) Expand all Loading... |
258 } | 260 } |
259 | 261 |
260 if (argc == 3) { | 262 if (argc == 3) { |
261 return CompareImages(argv[1], argv[2]); | 263 return CompareImages(argv[1], argv[2]); |
262 } | 264 } |
263 | 265 |
264 PrintHelp(); | 266 PrintHelp(); |
265 return kStatusError; | 267 return kStatusError; |
266 } | 268 } |
267 | 269 |
OLD | NEW |