Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(214)

Side by Side Diff: webkit/tools/test_shell/image_decoder_unittest.h

Issue 276016: Remove some deprecated file_util wstring functions. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: lint Created 11 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 #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 <vector> 9 #include <vector>
9 10
10 #include "Vector.h" 11 #include "Vector.h"
11 #include "ImageDecoder.h" 12 #include "ImageDecoder.h"
12 13
13 #undef LOG 14 #undef LOG
14 15
15 #include "base/basictypes.h" 16 #include "base/basictypes.h"
17 #include "base/file_path.h"
16 #include "testing/gtest/include/gtest/gtest.h" 18 #include "testing/gtest/include/gtest/gtest.h"
17 19
18 // If CALCULATE_MD5_SUMS is not defined, then this test decodes a handful of 20 // If CALCULATE_MD5_SUMS is not defined, then this test decodes a handful of
19 // image files and compares their MD5 sums to the stored sums on disk. 21 // image files and compares their MD5 sums to the stored sums on disk.
20 // 22 //
21 // To recalculate the MD5 sums, uncommment CALCULATE_MD5_SUMS. 23 // To recalculate the MD5 sums, uncommment CALCULATE_MD5_SUMS.
22 // 24 //
23 // The image files and corresponding MD5 sums live in the directory 25 // The image files and corresponding MD5 sums live in the directory
24 // chrome/test/data/*_decoder (where "*" is the format being tested). 26 // chrome/test/data/*_decoder (where "*" is the format being tested).
25 // 27 //
26 // Note: The MD5 sums calculated in this test by little- and big-endian systems 28 // Note: The MD5 sums calculated in this test by little- and big-endian systems
27 // will differ, since no endianness correction is done. If we start compiling 29 // will differ, since no endianness correction is done. If we start compiling
28 // for big endian machines this should be fixed. 30 // for big endian machines this should be fixed.
29 31
30 //#define CALCULATE_MD5_SUMS 32 //#define CALCULATE_MD5_SUMS
31 33
32 enum ImageDecoderTestFileSelection { 34 enum ImageDecoderTestFileSelection {
33 TEST_ALL, 35 TEST_ALL,
34 TEST_SMALLER, 36 TEST_SMALLER,
35 TEST_BIGGER, 37 TEST_BIGGER,
36 }; 38 };
37 39
38 // Reads the contents of the specified file into the specified vector. 40 // Reads the contents of the specified file into the specified vector.
39 void ReadFileToVector(const std::wstring& path, Vector<char>* contents); 41 void ReadFileToVector(const FilePath& path, Vector<char>* contents);
40 42
41 // Returns the path the decoded data is saved at. 43 // Returns the path the decoded data is saved at.
42 std::wstring GetMD5SumPath(const std::wstring& path); 44 FilePath GetMD5SumPath(const FilePath& path);
43 45
44 #ifdef CALCULATE_MD5_SUMS 46 #ifdef CALCULATE_MD5_SUMS
45 // Saves the MD5 sum to the specified file. 47 // Saves the MD5 sum to the specified file.
46 void SaveMD5Sum(const std::wstring& path, WebCore::RGBA32Buffer* buffer); 48 void SaveMD5Sum(const FilePath& path, WebCore::RGBA32Buffer* buffer);
47 #else 49 #else
48 // Verifies the image. |path| identifies the path the image was loaded from. 50 // Verifies the image. |path| identifies the path the image was loaded from.
49 // |frame_index| indicates which index from the decoder we should examine. 51 // |frame_index| indicates which index from the decoder we should examine.
50 void VerifyImage(WebCore::ImageDecoder* decoder, 52 void VerifyImage(WebCore::ImageDecoder* decoder,
51 const std::wstring& path, 53 const FilePath& path,
52 const std::wstring& md5_sum_path, 54 const FilePath& md5_sum_path,
53 size_t frame_index); 55 size_t frame_index);
54 #endif 56 #endif
55 57
56 class ImageDecoderTest : public testing::Test { 58 class ImageDecoderTest : public testing::Test {
57 public: 59 public:
58 explicit ImageDecoderTest(const std::wstring& format) : format_(format) { } 60 explicit ImageDecoderTest(const std::string& format) : format_(format) { }
59 61
60 protected: 62 protected:
61 virtual void SetUp(); 63 virtual void SetUp();
62 64
63 // Returns the vector of image files for testing. 65 // Returns the vector of image files for testing.
64 std::vector<std::wstring> GetImageFiles() const; 66 std::vector<FilePath> GetImageFiles() const;
65 67
66 // Returns true if the image is bogus and should not be successfully decoded. 68 // Returns true if the image is bogus and should not be successfully decoded.
67 bool ShouldImageFail(const std::wstring& path) const; 69 bool ShouldImageFail(const FilePath& path) const;
68 70
69 // Creates and returns an ImageDecoder for the file at the given |path|. If 71 // Creates and returns an ImageDecoder for the file at the given |path|. If
70 // |split_at_random| is true, also verifies that breaking the data supplied to 72 // |split_at_random| is true, also verifies that breaking the data supplied to
71 // the decoder into two random pieces does not cause problems. 73 // the decoder into two random pieces does not cause problems.
72 WebCore::ImageDecoder* SetupDecoder(const std::wstring& path, 74 WebCore::ImageDecoder* SetupDecoder(const FilePath& path,
73 bool split_at_random) const; 75 bool split_at_random) const;
74 76
75 // Verifies each of the test image files is decoded correctly and matches the 77 // Verifies each of the test image files is decoded correctly and matches the
76 // expected state. |file_selection| and |threshold| can be used to select 78 // expected state. |file_selection| and |threshold| can be used to select
77 // files to test based on file size. 79 // files to test based on file size.
78 void TestDecoding(ImageDecoderTestFileSelection file_selection, 80 void TestDecoding(ImageDecoderTestFileSelection file_selection,
79 const int64 threshold) const; 81 const int64 threshold) const;
80 82
81 void TestDecoding() const { 83 void TestDecoding() const {
82 TestDecoding(TEST_ALL, 0); 84 TestDecoding(TEST_ALL, 0);
83 } 85 }
84 86
85 #ifndef CALCULATE_MD5_SUMS 87 #ifndef CALCULATE_MD5_SUMS
86 // Verifies that decoding still works correctly when the files are split into 88 // Verifies that decoding still works correctly when the files are split into
87 // pieces at a random point. |file_selection| and |threshold| can be used to 89 // pieces at a random point. |file_selection| and |threshold| can be used to
88 // select files to test based on file size. 90 // select files to test based on file size.
89 void TestChunkedDecoding(ImageDecoderTestFileSelection file_selection, 91 void TestChunkedDecoding(ImageDecoderTestFileSelection file_selection,
90 const int64 threshold) const; 92 const int64 threshold) const;
91 93
92 void TestChunkedDecoding() const { 94 void TestChunkedDecoding() const {
93 TestChunkedDecoding(TEST_ALL, 0); 95 TestChunkedDecoding(TEST_ALL, 0);
94 } 96 }
95 97
96 #endif 98 #endif
97 99
98 // Returns the correct type of image decoder for this test. 100 // Returns the correct type of image decoder for this test.
99 virtual WebCore::ImageDecoder* CreateDecoder() const = 0; 101 virtual WebCore::ImageDecoder* CreateDecoder() const = 0;
100 102
101 // The format to be decoded, like "bmp" or "ico". 103 // The format to be decoded, like "bmp" or "ico".
102 std::wstring format_; 104 std::string format_;
103 105
104 protected: 106 protected:
105 // Path to the test files. 107 // Path to the test files.
106 std::wstring data_dir_; 108 FilePath data_dir_;
107 109
108 private: 110 private:
109 DISALLOW_EVIL_CONSTRUCTORS(ImageDecoderTest); 111 DISALLOW_COPY_AND_ASSIGN(ImageDecoderTest);
110 }; 112 };
111 113
112 #endif // WEBKIT_TOOLS_TEST_SHELL_IMAGE_DECODER_UNITTEST_H_ 114 #endif // WEBKIT_TOOLS_TEST_SHELL_IMAGE_DECODER_UNITTEST_H_
OLDNEW
« no previous file with comments | « webkit/default_plugin/plugin_database_handler.cc ('k') | webkit/tools/test_shell/image_decoder_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698