| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 "webkit/tools/test_shell/image_decoder_unittest.h" | 5 #include "webkit/tools/test_shell/image_decoder_unittest.h" |
| 6 | 6 |
| 7 #include "base/file_path.h" | 7 #include "base/file_path.h" |
| 8 #include "base/file_util.h" | 8 #include "base/file_util.h" |
| 9 #include "base/md5.h" | 9 #include "base/md5.h" |
| 10 #include "base/memory/scoped_ptr.h" | 10 #include "base/memory/scoped_ptr.h" |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 43 memcpy(&contents->at(0), raw_image_data.data(), raw_image_data.size()); | 43 memcpy(&contents->at(0), raw_image_data.data(), raw_image_data.size()); |
| 44 } | 44 } |
| 45 | 45 |
| 46 FilePath GetMD5SumPath(const FilePath& path) { | 46 FilePath GetMD5SumPath(const FilePath& path) { |
| 47 static const FilePath::StringType kDecodedDataExtension( | 47 static const FilePath::StringType kDecodedDataExtension( |
| 48 FILE_PATH_LITERAL(".md5sum")); | 48 FILE_PATH_LITERAL(".md5sum")); |
| 49 return FilePath(path.value() + kDecodedDataExtension); | 49 return FilePath(path.value() + kDecodedDataExtension); |
| 50 } | 50 } |
| 51 | 51 |
| 52 #if defined(CALCULATE_MD5_SUMS) | 52 #if defined(CALCULATE_MD5_SUMS) |
| 53 void SaveMD5Sum(const std::wstring& path, const WebKit::WebImage& web_image) { | 53 void SaveMD5Sum(const FilePath& path, const WebKit::WebImage& web_image) { |
| 54 // Calculate MD5 sum. | 54 // Calculate MD5 sum. |
| 55 base::MD5Digest digest; | 55 base::MD5Digest digest; |
| 56 web_image.getSkBitmap().lockPixels(); | 56 web_image.getSkBitmap().lockPixels(); |
| 57 base::MD5Sum(web_image.getSkBitmap().getPixels(), | 57 base::MD5Sum(web_image.getSkBitmap().getPixels(), |
| 58 web_image.getSkBitmap().width() * web_image.getSkBitmap().height() * | 58 web_image.getSkBitmap().width() * web_image.getSkBitmap().height() * |
| 59 sizeof(uint32_t), | 59 sizeof(uint32_t), |
| 60 &digest); | 60 &digest); |
| 61 | 61 |
| 62 // Write sum to disk. | 62 // Write sum to disk. |
| 63 int bytes_written = file_util::WriteFile(path, | 63 int bytes_written = file_util::WriteFile(path, |
| (...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 202 } | 202 } |
| 203 | 203 |
| 204 EXPECT_FALSE(decoder->isFailed()) << image_path.value(); | 204 EXPECT_FALSE(decoder->isFailed()) << image_path.value(); |
| 205 | 205 |
| 206 #ifdef CALCULATE_MD5_SUMS | 206 #ifdef CALCULATE_MD5_SUMS |
| 207 // Since WebImage does not expose get data by frame, get the size | 207 // Since WebImage does not expose get data by frame, get the size |
| 208 // through decoder and pass it to fromData so that the closest | 208 // through decoder and pass it to fromData so that the closest |
| 209 // image dats to the size is returned. | 209 // image dats to the size is returned. |
| 210 WebKit::WebSize size(decoder->getImage(desired_frame_index).size()); | 210 WebKit::WebSize size(decoder->getImage(desired_frame_index).size()); |
| 211 const WebKit::WebImage& image = WebKit::WebImage::fromData(data, size); | 211 const WebKit::WebImage& image = WebKit::WebImage::fromData(data, size); |
| 212 SaveMD5Sum(md5_sum_path.value(), image); | 212 SaveMD5Sum(md5_sum_path, image); |
| 213 #else | 213 #else |
| 214 VerifyImage(*decoder, image_path, md5_sum_path, desired_frame_index); | 214 VerifyImage(*decoder, image_path, md5_sum_path, desired_frame_index); |
| 215 #endif | 215 #endif |
| 216 } | 216 } |
| OLD | NEW |