| OLD | NEW |
| 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 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 #include "base/command_line.h" | 5 #include "base/command_line.h" |
| 6 #include "base/file_util.h" | 6 #include "base/file_util.h" |
| 7 #include "base/files/file_path.h" | 7 #include "base/files/file_path.h" |
| 8 #include "base/path_service.h" | 8 #include "base/path_service.h" |
| 9 #include "base/string_number_conversions.h" | 9 #include "base/string_number_conversions.h" |
| 10 #include "base/string_util.h" | 10 #include "base/string_util.h" |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 47 const char kGeneratedDir[] = "generated-dir"; | 47 const char kGeneratedDir[] = "generated-dir"; |
| 48 // Command line flag for overriding the default location for reference images. | 48 // Command line flag for overriding the default location for reference images. |
| 49 const char kReferenceDir[] = "reference-dir"; | 49 const char kReferenceDir[] = "reference-dir"; |
| 50 // Command line flag for Chromium build revision. | 50 // Command line flag for Chromium build revision. |
| 51 const char kBuildRevision[] = "build-revision"; | 51 const char kBuildRevision[] = "build-revision"; |
| 52 | 52 |
| 53 // Reads and decodes a PNG image to a bitmap. Returns true on success. The PNG | 53 // Reads and decodes a PNG image to a bitmap. Returns true on success. The PNG |
| 54 // should have been encoded using |gfx::PNGCodec::Encode|. | 54 // should have been encoded using |gfx::PNGCodec::Encode|. |
| 55 bool ReadPNGFile(const base::FilePath& file_path, SkBitmap* bitmap) { | 55 bool ReadPNGFile(const base::FilePath& file_path, SkBitmap* bitmap) { |
| 56 DCHECK(bitmap); | 56 DCHECK(bitmap); |
| 57 base::FilePath abs_path(file_path); | 57 base::FilePath abs_path(base::MakeAbsoluteFilePath(file_path)); |
| 58 if (!file_util::AbsolutePath(&abs_path)) | 58 if (abs_path.empty()) |
| 59 return false; | 59 return false; |
| 60 | 60 |
| 61 std::string png_data; | 61 std::string png_data; |
| 62 return file_util::ReadFileToString(abs_path, &png_data) && | 62 return file_util::ReadFileToString(abs_path, &png_data) && |
| 63 gfx::PNGCodec::Decode(reinterpret_cast<unsigned char*>(&png_data[0]), | 63 gfx::PNGCodec::Decode(reinterpret_cast<unsigned char*>(&png_data[0]), |
| 64 png_data.length(), | 64 png_data.length(), |
| 65 bitmap); | 65 bitmap); |
| 66 } | 66 } |
| 67 | 67 |
| 68 // Encodes a bitmap into a PNG and write to disk. Returns true on success. The | 68 // Encodes a bitmap into a PNG and write to disk. Returns true on success. The |
| (...skipping 483 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 552 | 552 |
| 553 gfx::Size container_size(400, 300); | 553 gfx::Size container_size(400, 300); |
| 554 base::FilePath url = | 554 base::FilePath url = |
| 555 test_data_dir().AppendASCII("pixel_browser_plugin.html"); | 555 test_data_dir().AppendASCII("pixel_browser_plugin.html"); |
| 556 RunPixelTest(container_size, url, ref_img_revision_update, | 556 RunPixelTest(container_size, url, ref_img_revision_update, |
| 557 ref_pixels, ref_pixel_count); | 557 ref_pixels, ref_pixel_count); |
| 558 } | 558 } |
| 559 | 559 |
| 560 } // namespace content | 560 } // namespace content |
| 561 | 561 |
| OLD | NEW |