OLD | NEW |
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 "content/test/image_decoder_test.h" | 5 #include "content/test/image_decoder_test.h" |
6 | 6 |
7 #include "base/file_util.h" | 7 #include "base/file_util.h" |
8 #include "base/files/file_enumerator.h" | 8 #include "base/files/file_enumerator.h" |
9 #include "base/files/file_path.h" | 9 #include "base/files/file_path.h" |
10 #include "base/md5.h" | 10 #include "base/md5.h" |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
54 void SaveMD5Sum(const base::FilePath& path, const blink::WebImage& web_image) { | 54 void SaveMD5Sum(const base::FilePath& path, const blink::WebImage& web_image) { |
55 // Calculate MD5 sum. | 55 // Calculate MD5 sum. |
56 base::MD5Digest digest; | 56 base::MD5Digest digest; |
57 web_image.getSkBitmap().lockPixels(); | 57 web_image.getSkBitmap().lockPixels(); |
58 base::MD5Sum(web_image.getSkBitmap().getPixels(), | 58 base::MD5Sum(web_image.getSkBitmap().getPixels(), |
59 web_image.getSkBitmap().width() * web_image.getSkBitmap().height() * | 59 web_image.getSkBitmap().width() * web_image.getSkBitmap().height() * |
60 sizeof(uint32_t), | 60 sizeof(uint32_t), |
61 &digest); | 61 &digest); |
62 | 62 |
63 // Write sum to disk. | 63 // Write sum to disk. |
64 int bytes_written = file_util::WriteFile(path, | 64 int bytes_written = base::WriteFile(path, |
65 reinterpret_cast<const char*>(&digest), sizeof digest); | 65 reinterpret_cast<const char*>(&digest), sizeof digest); |
66 ASSERT_EQ(sizeof digest, bytes_written); | 66 ASSERT_EQ(sizeof digest, bytes_written); |
67 web_image.getSkBitmap().unlockPixels(); | 67 web_image.getSkBitmap().unlockPixels(); |
68 } | 68 } |
69 #endif | 69 #endif |
70 | 70 |
71 #if !defined(CALCULATE_MD5_SUMS) | 71 #if !defined(CALCULATE_MD5_SUMS) |
72 void VerifyImage(const blink::WebImageDecoder& decoder, | 72 void VerifyImage(const blink::WebImageDecoder& decoder, |
73 const base::FilePath& path, | 73 const base::FilePath& path, |
74 const base::FilePath& md5_sum_path, | 74 const base::FilePath& md5_sum_path, |
(...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
217 // Since WebImage does not expose get data by frame, get the size | 217 // Since WebImage does not expose get data by frame, get the size |
218 // through decoder and pass it to fromData so that the closest | 218 // through decoder and pass it to fromData so that the closest |
219 // image dats to the size is returned. | 219 // image dats to the size is returned. |
220 blink::WebSize size(decoder->getImage(desired_frame_index).size()); | 220 blink::WebSize size(decoder->getImage(desired_frame_index).size()); |
221 const blink::WebImage& image = blink::WebImage::fromData(data, size); | 221 const blink::WebImage& image = blink::WebImage::fromData(data, size); |
222 SaveMD5Sum(md5_sum_path, image); | 222 SaveMD5Sum(md5_sum_path, image); |
223 #else | 223 #else |
224 VerifyImage(*decoder, image_path, md5_sum_path, desired_frame_index); | 224 VerifyImage(*decoder, image_path, md5_sum_path, desired_frame_index); |
225 #endif | 225 #endif |
226 } | 226 } |
OLD | NEW |