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/files/file_enumerator.h" | 7 #include "base/files/file_enumerator.h" |
8 #include "base/files/file_path.h" | 8 #include "base/files/file_path.h" |
9 #include "base/files/file_util.h" | 9 #include "base/files/file_util.h" |
10 #include "base/md5.h" | 10 #include "base/md5.h" |
11 #include "base/memory/scoped_ptr.h" | 11 #include "base/memory/scoped_ptr.h" |
12 #include "base/path_service.h" | 12 #include "base/path_service.h" |
| 13 #include "base/strings/pattern.h" |
13 #include "base/strings/string_util.h" | 14 #include "base/strings/string_util.h" |
14 #include "base/strings/utf_string_conversions.h" | 15 #include "base/strings/utf_string_conversions.h" |
15 #include "third_party/WebKit/public/platform/WebData.h" | 16 #include "third_party/WebKit/public/platform/WebData.h" |
16 #include "third_party/WebKit/public/platform/WebImage.h" | 17 #include "third_party/WebKit/public/platform/WebImage.h" |
17 #include "third_party/WebKit/public/platform/WebSize.h" | 18 #include "third_party/WebKit/public/platform/WebSize.h" |
18 #include "third_party/WebKit/public/web/WebImageDecoder.h" | 19 #include "third_party/WebKit/public/web/WebImageDecoder.h" |
19 | 20 |
20 // Uncomment this to recalculate the MD5 sums; see header comments. | 21 // Uncomment this to recalculate the MD5 sums; see header comments. |
21 // #define CALCULATE_MD5_SUMS | 22 // #define CALCULATE_MD5_SUMS |
22 | 23 |
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
125 base::FileEnumerator::FILES); | 126 base::FileEnumerator::FILES); |
126 std::vector<base::FilePath> image_files; | 127 std::vector<base::FilePath> image_files; |
127 for (base::FilePath next_file_name = enumerator.Next(); | 128 for (base::FilePath next_file_name = enumerator.Next(); |
128 !next_file_name.empty(); next_file_name = enumerator.Next()) { | 129 !next_file_name.empty(); next_file_name = enumerator.Next()) { |
129 base::FilePath base_name = next_file_name.BaseName(); | 130 base::FilePath base_name = next_file_name.BaseName(); |
130 #if defined(OS_WIN) | 131 #if defined(OS_WIN) |
131 std::string base_name_ascii = base::UTF16ToASCII(base_name.value()); | 132 std::string base_name_ascii = base::UTF16ToASCII(base_name.value()); |
132 #else | 133 #else |
133 std::string base_name_ascii = base_name.value(); | 134 std::string base_name_ascii = base_name.value(); |
134 #endif | 135 #endif |
135 if (MatchPattern(base_name_ascii, pattern)) | 136 if (base::MatchPattern(base_name_ascii, pattern)) |
136 image_files.push_back(next_file_name); | 137 image_files.push_back(next_file_name); |
137 } | 138 } |
138 | 139 |
139 return image_files; | 140 return image_files; |
140 } | 141 } |
141 | 142 |
142 bool ImageDecoderTest::ShouldImageFail(const base::FilePath& path) const { | 143 bool ImageDecoderTest::ShouldImageFail(const base::FilePath& path) const { |
143 const base::FilePath::StringType kBadSuffix(FILE_PATH_LITERAL(".bad.")); | 144 const base::FilePath::StringType kBadSuffix(FILE_PATH_LITERAL(".bad.")); |
144 return (path.value().length() > (kBadSuffix.length() + format_.length()) && | 145 return (path.value().length() > (kBadSuffix.length() + format_.length()) && |
145 !path.value().compare(path.value().length() - format_.length() - | 146 !path.value().compare(path.value().length() - format_.length() - |
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
201 EXPECT_TRUE(decoder->isFailed()); | 202 EXPECT_TRUE(decoder->isFailed()); |
202 } else { | 203 } else { |
203 EXPECT_FALSE(decoder->isFailed()) << image_path.value(); | 204 EXPECT_FALSE(decoder->isFailed()) << image_path.value(); |
204 #if defined(CALCULATE_MD5_SUMS) | 205 #if defined(CALCULATE_MD5_SUMS) |
205 SaveMD5Sum(md5_sum_path, decoder->getFrameAtIndex(desired_frame_index)); | 206 SaveMD5Sum(md5_sum_path, decoder->getFrameAtIndex(desired_frame_index)); |
206 #else | 207 #else |
207 VerifyImage(*decoder, image_path, md5_sum_path, desired_frame_index); | 208 VerifyImage(*decoder, image_path, md5_sum_path, desired_frame_index); |
208 #endif | 209 #endif |
209 } | 210 } |
210 } | 211 } |
OLD | NEW |