diff options
author | pkasting@chromium.org <pkasting@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-07-27 20:41:27 +0000 |
---|---|---|
committer | pkasting@chromium.org <pkasting@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-07-27 20:41:27 +0000 |
commit | 497e342c070df49e9cbe1e9f8c39e31477fb11ff (patch) | |
tree | 7b8e200c4bd6c6599e9229fde271d9af1ffdb872 /webkit/tools/webcore_unit_tests | |
parent | aa15ca70b58a09192d3367070f6c7a14fac0887c (diff) | |
download | chromium_src-497e342c070df49e9cbe1e9f8c39e31477fb11ff.zip chromium_src-497e342c070df49e9cbe1e9f8c39e31477fb11ff.tar.gz chromium_src-497e342c070df49e9cbe1e9f8c39e31477fb11ff.tar.bz2 |
Refactor the "load and decode" portion of the image decoder unittest into a helper function, so that it will be easier for the ICO favicon test to ask for a particular frame.
Right now this isn't necessary; that test still wants frame 0. After I land some patches upstream, however, this will change (and all the "testing_favicon_size_" crap will disappear, it's just a temporary hack).
BUG=none
TEST=Covered by existing unittests
Review URL: http://codereview.chromium.org/160123
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@21692 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'webkit/tools/webcore_unit_tests')
-rw-r--r-- | webkit/tools/webcore_unit_tests/ICOImageDecoder_unittest.cpp | 31 |
1 files changed, 17 insertions, 14 deletions
diff --git a/webkit/tools/webcore_unit_tests/ICOImageDecoder_unittest.cpp b/webkit/tools/webcore_unit_tests/ICOImageDecoder_unittest.cpp index 3d6b0f9..b3eb5f2 100644 --- a/webkit/tools/webcore_unit_tests/ICOImageDecoder_unittest.cpp +++ b/webkit/tools/webcore_unit_tests/ICOImageDecoder_unittest.cpp @@ -39,12 +39,18 @@ static const int kFavIconSize = 16; class ICOImageDecoderTest : public ImageDecoderTest { public: - ICOImageDecoderTest() : ImageDecoderTest(L"ico") { } + ICOImageDecoderTest() : ImageDecoderTest(L"ico"), + testing_favicon_size_(false) { } protected: virtual WebCore::ImageDecoder* CreateDecoder() const { - return new WebCore::ICOImageDecoder(WebCore::IntSize()); + WebCore::IntSize desired_size; + if (testing_favicon_size_) + desired_size = WebCore::IntSize(kFavIconSize, kFavIconSize); + return new WebCore::ICOImageDecoder(desired_size); } + + bool testing_favicon_size_; }; TEST_F(ICOImageDecoderTest, Decoding) { @@ -59,26 +65,23 @@ TEST_F(ICOImageDecoderTest, ChunkedDecoding) { TEST_F(ICOImageDecoderTest, FaviconSize) { // Test that the decoder decodes a preferred size when specified. + testing_favicon_size_ = true; // Load an icon that has both favicon-size and larger entries. std::wstring multisize_icon_path(data_dir_); file_util::AppendToPath(&multisize_icon_path, L"yahoo.ico"); - Vector<char> image_contents; - ReadFileToVector(multisize_icon_path, &image_contents); - - // Decode, preferring the favicon size. - scoped_ptr<WebCore::ImageDecoder> decoder(new WebCore::ICOImageDecoder( - WebCore::IntSize(kFavIconSize, kFavIconSize))); - RefPtr<WebCore::SharedBuffer> shared_contents(WebCore::SharedBuffer::create()); - shared_contents->append(image_contents.data(), - static_cast<int>(image_contents.size())); - decoder->setData(shared_contents.get(), true); + scoped_ptr<WebCore::ImageDecoder> decoder(SetupDecoder(multisize_icon_path, + false)); // Verify the decoding. const std::wstring md5_sum_path(GetMD5SumPath(multisize_icon_path) + L"2"); + static const int kDesiredFrameIndex = 0; #ifdef CALCULATE_MD5_SUMS - SaveMD5Sum(md5_sum_path, decoder->frameBufferAtIndex(0)); + SaveMD5Sum(md5_sum_path, decoder->frameBufferAtIndex(kDesiredFrameIndex)); #else - VerifyImage(decoder.get(), multisize_icon_path, md5_sum_path); + VerifyImage(decoder.get(), multisize_icon_path, md5_sum_path, + kDesiredFrameIndex); #endif + + testing_favicon_size_ = false; } |