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

Side by Side Diff: cc/test/pixel_test_utils.cc

Issue 19579005: Move ReadFileToString to the base namespace. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 3 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 | « base/test/test_file_util_win.cc ('k') | cc/trees/layer_tree_host_perftest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 "cc/test/pixel_test_utils.h" 5 #include "cc/test/pixel_test_utils.h"
6 6
7 #include <string> 7 #include <string>
8 #include <vector> 8 #include <vector>
9 9
10 #include "base/file_util.h" 10 #include "base/file_util.h"
(...skipping 13 matching lines...) Expand all
24 char* data = reinterpret_cast<char*>(&png_data[0]); 24 char* data = reinterpret_cast<char*>(&png_data[0]);
25 int size = static_cast<int>(png_data.size()); 25 int size = static_cast<int>(png_data.size());
26 return file_util::WriteFile(file_path, data, size) == size; 26 return file_util::WriteFile(file_path, data, size) == size;
27 } 27 }
28 return false; 28 return false;
29 } 29 }
30 30
31 bool ReadPNGFile(const base::FilePath& file_path, SkBitmap* bitmap) { 31 bool ReadPNGFile(const base::FilePath& file_path, SkBitmap* bitmap) {
32 DCHECK(bitmap); 32 DCHECK(bitmap);
33 std::string png_data; 33 std::string png_data;
34 return file_util::ReadFileToString(file_path, &png_data) && 34 return base::ReadFileToString(file_path, &png_data) &&
35 gfx::PNGCodec::Decode(reinterpret_cast<unsigned char*>(&png_data[0]), 35 gfx::PNGCodec::Decode(reinterpret_cast<unsigned char*>(&png_data[0]),
36 png_data.length(), 36 png_data.length(),
37 bitmap); 37 bitmap);
38 } 38 }
39 39
40 bool MatchesPNGFile(const SkBitmap& gen_bmp, base::FilePath ref_img_path, 40 bool MatchesPNGFile(const SkBitmap& gen_bmp, base::FilePath ref_img_path,
41 const PixelComparator& comparator) { 41 const PixelComparator& comparator) {
42 SkBitmap ref_bmp; 42 SkBitmap ref_bmp;
43 if (!ReadPNGFile(ref_img_path, &ref_bmp)) { 43 if (!ReadPNGFile(ref_img_path, &ref_bmp)) {
44 LOG(ERROR) << "Cannot read reference image: " << ref_img_path.value(); 44 LOG(ERROR) << "Cannot read reference image: " << ref_img_path.value();
(...skipping 12 matching lines...) Expand all
57 } 57 }
58 58
59 // Shortcut for empty images. They are always equal. 59 // Shortcut for empty images. They are always equal.
60 if (gen_bmp.width() == 0 || gen_bmp.height() == 0) 60 if (gen_bmp.width() == 0 || gen_bmp.height() == 0)
61 return true; 61 return true;
62 62
63 return comparator.Compare(gen_bmp, ref_bmp); 63 return comparator.Compare(gen_bmp, ref_bmp);
64 } 64 }
65 65
66 } // namespace cc 66 } // namespace cc
OLDNEW
« no previous file with comments | « base/test/test_file_util_win.cc ('k') | cc/trees/layer_tree_host_perftest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698