| 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_util.h" | 9 #include "base/file_util.h" |
| 10 #include "base/md5.h" | 10 #include "base/md5.h" |
| (...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 147 | 147 |
| 148 if (split_at_random) { | 148 if (split_at_random) { |
| 149 // Split the file at an arbitrary point. | 149 // Split the file at an arbitrary point. |
| 150 const int partial_size = static_cast<int>( | 150 const int partial_size = static_cast<int>( |
| 151 (static_cast<double>(rand()) / RAND_MAX) * image_contents.size()); | 151 (static_cast<double>(rand()) / RAND_MAX) * image_contents.size()); |
| 152 shared_contents->append(image_contents.data(), partial_size); | 152 shared_contents->append(image_contents.data(), partial_size); |
| 153 | 153 |
| 154 // Make sure the image decoder doesn't fail when we ask for the frame buffer | 154 // Make sure the image decoder doesn't fail when we ask for the frame buffer |
| 155 // for this partial image. | 155 // for this partial image. |
| 156 decoder->setData(shared_contents.get(), false); | 156 decoder->setData(shared_contents.get(), false); |
| 157 EXPECT_NE(static_cast<WebCore::RGBA32Buffer*>(NULL), | |
| 158 decoder->frameBufferAtIndex(0)) << path; | |
| 159 EXPECT_FALSE(decoder->failed()) << path; | 157 EXPECT_FALSE(decoder->failed()) << path; |
| 158 // NOTE: We can't check that frame 0 is non-NULL, because if this is an ICO |
| 159 // and we haven't yet supplied enough data to read the directory, there is |
| 160 // no framecount and thus no first frame. |
| 160 | 161 |
| 161 // Make sure passing the complete image results in successful decoding. | 162 // Make sure passing the complete image results in successful decoding. |
| 162 shared_contents->append( | 163 shared_contents->append( |
| 163 &image_contents.data()[partial_size], | 164 &image_contents.data()[partial_size], |
| 164 static_cast<int>(image_contents.size() - partial_size)); | 165 static_cast<int>(image_contents.size() - partial_size)); |
| 165 } else { | 166 } else { |
| 166 shared_contents->append(image_contents.data(), | 167 shared_contents->append(image_contents.data(), |
| 167 static_cast<int>(image_contents.size())); | 168 static_cast<int>(image_contents.size())); |
| 168 } | 169 } |
| 169 | 170 |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 218 continue; | 219 continue; |
| 219 | 220 |
| 220 if (ShouldImageFail(*i)) | 221 if (ShouldImageFail(*i)) |
| 221 continue; | 222 continue; |
| 222 | 223 |
| 223 scoped_ptr<WebCore::ImageDecoder> decoder(SetupDecoder(*i, true)); | 224 scoped_ptr<WebCore::ImageDecoder> decoder(SetupDecoder(*i, true)); |
| 224 VerifyImage(decoder.get(), *i, GetMD5SumPath(*i), 0); | 225 VerifyImage(decoder.get(), *i, GetMD5SumPath(*i), 0); |
| 225 } | 226 } |
| 226 } | 227 } |
| 227 #endif | 228 #endif |
| OLD | NEW |