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

Side by Side Diff: Source/platform/image-decoders/ImageDecoderTest.cpp

Issue 1184673003: Fix unit test style in Source/platform/, part 2. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 5 years, 6 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 /* 1 /*
2 * Copyright (C) 2013 Google Inc. All rights reserved. 2 * Copyright (C) 2013 Google Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are 5 * modification, are permitted provided that the following conditions are
6 * met: 6 * met:
7 * 7 *
8 * * Redistributions of source code must retain the above copyright 8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * * Redistributions in binary form must reproduce the above 10 * * Redistributions in binary form must reproduce the above
(...skipping 11 matching lines...) Expand all
22 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 22 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
23 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 23 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
24 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 24 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29 */ 29 */
30 30
31 #include "config.h" 31 #include "config.h"
32
33 #include "platform/image-decoders/ImageDecoder.h" 32 #include "platform/image-decoders/ImageDecoder.h"
34 33
35 #include "platform/image-decoders/ImageFrame.h" 34 #include "platform/image-decoders/ImageFrame.h"
36 #include "wtf/OwnPtr.h" 35 #include "wtf/OwnPtr.h"
37 #include "wtf/PassOwnPtr.h" 36 #include "wtf/PassOwnPtr.h"
38 #include "wtf/Vector.h" 37 #include "wtf/Vector.h"
39 #include <gtest/gtest.h> 38 #include <gtest/gtest.h>
40 39
41 using namespace blink; 40 namespace blink {
42 41
43 class TestImageDecoder : public ImageDecoder { 42 class TestImageDecoder : public ImageDecoder {
44 public: 43 public:
45 TestImageDecoder() 44 TestImageDecoder()
46 : ImageDecoder(ImageSource::AlphaNotPremultiplied, ImageSource::GammaAnd ColorProfileApplied, noDecodedImageByteLimit) 45 : ImageDecoder(ImageSource::AlphaNotPremultiplied, ImageSource::GammaAnd ColorProfileApplied, noDecodedImageByteLimit)
47 { 46 {
48 } 47 }
49 48
50 virtual String filenameExtension() const override { return ""; } 49 String filenameExtension() const override { return ""; }
51 50
52 Vector<ImageFrame, 1>& frameBufferCache() 51 Vector<ImageFrame, 1>& frameBufferCache()
53 { 52 {
54 return m_frameBufferCache; 53 return m_frameBufferCache;
55 } 54 }
56 55
57 void resetRequiredPreviousFrames(bool knownOpaque = false) 56 void resetRequiredPreviousFrames(bool knownOpaque = false)
58 { 57 {
59 for (size_t i = 0; i < m_frameBufferCache.size(); ++i) 58 for (size_t i = 0; i < m_frameBufferCache.size(); ++i)
60 m_frameBufferCache[i].setRequiredPreviousFrameIndex(findRequiredPrev iousFrame(i, knownOpaque)); 59 m_frameBufferCache[i].setRequiredPreviousFrameIndex(findRequiredPrev iousFrame(i, knownOpaque));
61 } 60 }
62 61
63 void initFrames(size_t numFrames, unsigned width = 100, unsigned height = 10 0) 62 void initFrames(size_t numFrames, unsigned width = 100, unsigned height = 10 0)
64 { 63 {
65 setSize(width, height); 64 setSize(width, height);
66 m_frameBufferCache.resize(numFrames); 65 m_frameBufferCache.resize(numFrames);
67 for (size_t i = 0; i < numFrames; ++i) 66 for (size_t i = 0; i < numFrames; ++i)
68 m_frameBufferCache[i].setOriginalFrameRect(IntRect(0, 0, width, heig ht)); 67 m_frameBufferCache[i].setOriginalFrameRect(IntRect(0, 0, width, heig ht));
69 } 68 }
70 69
71 private: 70 private:
72 virtual void decodeSize() override { } 71 void decodeSize() override { }
73 virtual void decode(size_t index) override { } 72 void decode(size_t index) override { }
74 }; 73 };
75 74
76 TEST(ImageDecoderTest, sizeCalculationMayOverflow) 75 TEST(ImageDecoderTest, sizeCalculationMayOverflow)
77 { 76 {
78 OwnPtr<TestImageDecoder> decoder(adoptPtr(new TestImageDecoder())); 77 OwnPtr<TestImageDecoder> decoder(adoptPtr(new TestImageDecoder()));
79 EXPECT_FALSE(decoder->setSize(1 << 29, 1)); 78 EXPECT_FALSE(decoder->setSize(1 << 29, 1));
80 EXPECT_FALSE(decoder->setSize(1, 1 << 29)); 79 EXPECT_FALSE(decoder->setSize(1, 1 << 29));
81 EXPECT_FALSE(decoder->setSize(1 << 15, 1 << 15)); 80 EXPECT_FALSE(decoder->setSize(1 << 15, 1 << 15));
82 EXPECT_TRUE(decoder->setSize(1 << 28, 1)); 81 EXPECT_TRUE(decoder->setSize(1 << 28, 1));
83 EXPECT_TRUE(decoder->setSize(1, 1 << 28)); 82 EXPECT_TRUE(decoder->setSize(1, 1 << 28));
(...skipping 159 matching lines...) Expand 10 before | Expand all | Expand 10 after
243 decoder->resetRequiredPreviousFrames(); 242 decoder->resetRequiredPreviousFrames();
244 decoder->clearCacheExceptFrame(5); 243 decoder->clearCacheExceptFrame(5);
245 for (size_t i = 0; i < numFrames; ++i) { 244 for (size_t i = 0; i < numFrames; ++i) {
246 SCOPED_TRACE(testing::Message() << i); 245 SCOPED_TRACE(testing::Message() << i);
247 if (i == 5) 246 if (i == 5)
248 EXPECT_EQ(ImageFrame::FrameComplete, frameBuffers[i].status()); 247 EXPECT_EQ(ImageFrame::FrameComplete, frameBuffers[i].status());
249 else 248 else
250 EXPECT_EQ(ImageFrame::FrameEmpty, frameBuffers[i].status()); 249 EXPECT_EQ(ImageFrame::FrameEmpty, frameBuffers[i].status());
251 } 250 }
252 } 251 }
252
253 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698