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 #ifndef WEBKIT_TOOLS_TEST_SHELL_IMAGE_DECODER_UNITTEST_H_ | 5 #ifndef WEBKIT_TOOLS_TEST_SHELL_IMAGE_DECODER_UNITTEST_H_ |
6 #define WEBKIT_TOOLS_TEST_SHELL_IMAGE_DECODER_UNITTEST_H_ | 6 #define WEBKIT_TOOLS_TEST_SHELL_IMAGE_DECODER_UNITTEST_H_ |
7 | 7 |
8 #include <string> | 8 #include <string> |
9 #include <vector> | 9 #include <vector> |
10 | 10 |
(...skipping 19 matching lines...) Expand all Loading... |
30 | 30 |
31 // #define CALCULATE_MD5_SUMS | 31 // #define CALCULATE_MD5_SUMS |
32 | 32 |
33 enum ImageDecoderTestFileSelection { | 33 enum ImageDecoderTestFileSelection { |
34 TEST_ALL, | 34 TEST_ALL, |
35 TEST_SMALLER, | 35 TEST_SMALLER, |
36 TEST_BIGGER, | 36 TEST_BIGGER, |
37 }; | 37 }; |
38 | 38 |
39 // Returns the path the decoded data is saved at. | 39 // Returns the path the decoded data is saved at. |
40 FilePath GetMD5SumPath(const FilePath& path); | 40 base::FilePath GetMD5SumPath(const base::FilePath& path); |
41 | 41 |
42 class ImageDecoderTest : public testing::Test { | 42 class ImageDecoderTest : public testing::Test { |
43 public: | 43 public: |
44 explicit ImageDecoderTest(const std::string& format) : format_(format) { } | 44 explicit ImageDecoderTest(const std::string& format) : format_(format) { } |
45 | 45 |
46 protected: | 46 protected: |
47 virtual void SetUp() OVERRIDE; | 47 virtual void SetUp() OVERRIDE; |
48 | 48 |
49 // Returns the vector of image files for testing. | 49 // Returns the vector of image files for testing. |
50 std::vector<FilePath> GetImageFiles() const; | 50 std::vector<base::FilePath> GetImageFiles() const; |
51 | 51 |
52 // Returns true if the image is bogus and should not be successfully decoded. | 52 // Returns true if the image is bogus and should not be successfully decoded. |
53 bool ShouldImageFail(const FilePath& path) const; | 53 bool ShouldImageFail(const base::FilePath& path) const; |
54 | 54 |
55 // Tests if decoder decodes image at image_path with underlying frame at | 55 // Tests if decoder decodes image at image_path with underlying frame at |
56 // index desired_frame_index. The md5_sum_path is needed if the test is not | 56 // index desired_frame_index. The md5_sum_path is needed if the test is not |
57 // asked to generate one i.e. if # #define CALCULATE_MD5_SUMS is set. | 57 // asked to generate one i.e. if # #define CALCULATE_MD5_SUMS is set. |
58 void TestWebKitImageDecoder(const FilePath& image_path, | 58 void TestWebKitImageDecoder(const base::FilePath& image_path, |
59 const FilePath& md5_sum_path, int desired_frame_index) const; | 59 const base::FilePath& md5_sum_path, int desired_frame_index) const; |
60 | 60 |
61 // Verifies each of the test image files is decoded correctly and matches the | 61 // Verifies each of the test image files is decoded correctly and matches the |
62 // expected state. |file_selection| and |threshold| can be used to select | 62 // expected state. |file_selection| and |threshold| can be used to select |
63 // files to test based on file size. | 63 // files to test based on file size. |
64 // If just the MD5 sum is wanted, this skips chunking. | 64 // If just the MD5 sum is wanted, this skips chunking. |
65 void TestDecoding(ImageDecoderTestFileSelection file_selection, | 65 void TestDecoding(ImageDecoderTestFileSelection file_selection, |
66 const int64 threshold); | 66 const int64 threshold); |
67 | 67 |
68 void TestDecoding() { | 68 void TestDecoding() { |
69 TestDecoding(TEST_ALL, 0); | 69 TestDecoding(TEST_ALL, 0); |
70 } | 70 } |
71 | 71 |
72 // Creates WebKit API's decoder. | 72 // Creates WebKit API's decoder. |
73 virtual WebKit::WebImageDecoder* CreateWebKitImageDecoder() const = 0; | 73 virtual WebKit::WebImageDecoder* CreateWebKitImageDecoder() const = 0; |
74 | 74 |
75 // The format to be decoded, like "bmp" or "ico". | 75 // The format to be decoded, like "bmp" or "ico". |
76 std::string format_; | 76 std::string format_; |
77 | 77 |
78 protected: | 78 protected: |
79 // Path to the test files. | 79 // Path to the test files. |
80 FilePath data_dir_; | 80 base::FilePath data_dir_; |
81 | 81 |
82 private: | 82 private: |
83 DISALLOW_COPY_AND_ASSIGN(ImageDecoderTest); | 83 DISALLOW_COPY_AND_ASSIGN(ImageDecoderTest); |
84 }; | 84 }; |
85 | 85 |
86 #endif // WEBKIT_TOOLS_TEST_SHELL_IMAGE_DECODER_UNITTEST_H_ | 86 #endif // WEBKIT_TOOLS_TEST_SHELL_IMAGE_DECODER_UNITTEST_H_ |
OLD | NEW |