OLD | NEW |
1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2008 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 "config.h" | 5 #include "config.h" |
6 | 6 |
7 #include "webkit/tools/test_shell/image_decoder_unittest.h" | 7 #include "webkit/tools/test_shell/image_decoder_unittest.h" |
8 | 8 |
| 9 #include "base/file_path.h" |
9 #include "base/file_util.h" | 10 #include "base/file_util.h" |
10 #include "base/md5.h" | 11 #include "base/md5.h" |
11 #include "base/path_service.h" | 12 #include "base/path_service.h" |
12 #include "base/scoped_ptr.h" | 13 #include "base/scoped_ptr.h" |
13 #include "base/string_util.h" | 14 #include "base/string_util.h" |
14 #include "base/time.h" | 15 #include "base/time.h" |
15 | 16 |
16 using base::Time; | 17 using base::Time; |
17 | 18 |
18 void ReadFileToVector(const std::wstring& path, Vector<char>* contents) { | 19 void ReadFileToVector(const std::wstring& path, Vector<char>* contents) { |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
71 ASSERT_EQ(sizeof expected_digest, file_bytes.size()) << path; | 72 ASSERT_EQ(sizeof expected_digest, file_bytes.size()) << path; |
72 memcpy(&expected_digest, file_bytes.data(), sizeof expected_digest); | 73 memcpy(&expected_digest, file_bytes.data(), sizeof expected_digest); |
73 | 74 |
74 // Verify that the sums are the same. | 75 // Verify that the sums are the same. |
75 EXPECT_EQ(0, memcmp(&expected_digest, &actual_digest, sizeof(MD5Digest))) << | 76 EXPECT_EQ(0, memcmp(&expected_digest, &actual_digest, sizeof(MD5Digest))) << |
76 path; | 77 path; |
77 } | 78 } |
78 #endif | 79 #endif |
79 | 80 |
80 void ImageDecoderTest::SetUp() { | 81 void ImageDecoderTest::SetUp() { |
81 ASSERT_TRUE(PathService::Get(base::DIR_SOURCE_ROOT, &data_dir_)); | 82 FilePath data_dir; |
| 83 ASSERT_TRUE(PathService::Get(base::DIR_SOURCE_ROOT, &data_dir)); |
| 84 data_dir_ = data_dir.ToWStringHack(); |
82 file_util::AppendToPath(&data_dir_, L"webkit"); | 85 file_util::AppendToPath(&data_dir_, L"webkit"); |
83 file_util::AppendToPath(&data_dir_, L"data"); | 86 file_util::AppendToPath(&data_dir_, L"data"); |
84 file_util::AppendToPath(&data_dir_, format_ + L"_decoder"); | 87 file_util::AppendToPath(&data_dir_, format_ + L"_decoder"); |
85 ASSERT_TRUE(file_util::PathExists(data_dir_)) << data_dir_; | 88 ASSERT_TRUE(file_util::PathExists(data_dir_)) << data_dir_; |
86 } | 89 } |
87 | 90 |
88 std::vector<std::wstring> ImageDecoderTest::GetImageFiles() const { | 91 std::vector<std::wstring> ImageDecoderTest::GetImageFiles() const { |
89 std::wstring pattern = L"*." + format_; | 92 std::wstring pattern = L"*." + format_; |
90 | 93 |
91 file_util::FileEnumerator enumerator(FilePath::FromWStringHack(data_dir_), | 94 file_util::FileEnumerator enumerator(FilePath::FromWStringHack(data_dir_), |
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
177 | 180 |
178 // Make sure passing the complete image results in successful decoding. | 181 // Make sure passing the complete image results in successful decoding. |
179 partial_contents->append( | 182 partial_contents->append( |
180 &image_contents.data()[partial_size], | 183 &image_contents.data()[partial_size], |
181 static_cast<int>(image_contents.size() - partial_size)); | 184 static_cast<int>(image_contents.size() - partial_size)); |
182 decoder->setData(partial_contents.get(), true); | 185 decoder->setData(partial_contents.get(), true); |
183 VerifyImage(decoder.get(), *i, GetMD5SumPath(*i)); | 186 VerifyImage(decoder.get(), *i, GetMD5SumPath(*i)); |
184 } | 187 } |
185 } | 188 } |
186 #endif | 189 #endif |
OLD | NEW |