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

Side by Side Diff: Source/platform/graphics/ImageDecodingStoreTest.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) 2012 Google Inc. All rights reserved. 2 * Copyright (C) 2012 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 5 * modification, are permitted provided that the following conditions
6 * are met: 6 * are met:
7 * 7 *
8 * 1. Redistributions of source code must retain the above copyright 8 * 1. 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 * 2. Redistributions in binary form must reproduce the above copyright 10 * 2. Redistributions in binary form must reproduce the above copyright
11 * notice, this list of conditions and the following disclaimer in the 11 * notice, this list of conditions and the following disclaimer in the
12 * documentation and/or other materials provided with the distribution. 12 * documentation and/or other materials provided with the distribution.
13 * 13 *
14 * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY 14 * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY
15 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 15 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
16 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 16 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
17 * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY 17 * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY
18 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 18 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
19 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 19 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
20 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 20 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
21 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 21 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
22 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF 22 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
23 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 23 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
24 */ 24 */
25 25
26 #include "config.h" 26 #include "config.h"
27
28 #include "platform/graphics/ImageDecodingStore.h" 27 #include "platform/graphics/ImageDecodingStore.h"
29 28
30 #include "platform/SharedBuffer.h" 29 #include "platform/SharedBuffer.h"
31 #include "platform/graphics/ImageFrameGenerator.h" 30 #include "platform/graphics/ImageFrameGenerator.h"
32 #include "platform/graphics/test/MockImageDecoder.h" 31 #include "platform/graphics/test/MockImageDecoder.h"
33 #include <gtest/gtest.h> 32 #include <gtest/gtest.h>
34 33
35 using namespace blink; 34 namespace blink {
36
37 namespace {
38 35
39 class ImageDecodingStoreTest : public ::testing::Test, public MockImageDecoderCl ient { 36 class ImageDecodingStoreTest : public ::testing::Test, public MockImageDecoderCl ient {
40 public: 37 public:
41 virtual void SetUp() 38 void SetUp() override
42 { 39 {
43 ImageDecodingStore::instance().setCacheLimitInBytes(1024 * 1024); 40 ImageDecodingStore::instance().setCacheLimitInBytes(1024 * 1024);
44 m_data = SharedBuffer::create(); 41 m_data = SharedBuffer::create();
45 m_generator = ImageFrameGenerator::create(SkISize::Make(100, 100), m_dat a, true); 42 m_generator = ImageFrameGenerator::create(SkISize::Make(100, 100), m_dat a, true);
46 m_decodersDestroyed = 0; 43 m_decodersDestroyed = 0;
47 } 44 }
48 45
49 virtual void TearDown() 46 void TearDown() override
50 { 47 {
51 ImageDecodingStore::instance().clear(); 48 ImageDecodingStore::instance().clear();
52 } 49 }
53 50
54 virtual void decoderBeingDestroyed() 51 void decoderBeingDestroyed() override
55 { 52 {
56 ++m_decodersDestroyed; 53 ++m_decodersDestroyed;
57 } 54 }
58 55
59 virtual void decodeRequested() 56 void decodeRequested() override
60 { 57 {
61 // Decoder is never used by ImageDecodingStore. 58 // Decoder is never used by ImageDecodingStore.
62 ASSERT_TRUE(false); 59 ASSERT_TRUE(false);
63 } 60 }
64 61
65 virtual ImageFrame::Status status() 62 ImageFrame::Status status() override
66 { 63 {
67 return ImageFrame::FramePartial; 64 return ImageFrame::FramePartial;
68 } 65 }
69 66
70 virtual size_t frameCount() { return 1; } 67 size_t frameCount() override { return 1; }
71 virtual int repetitionCount() const { return cAnimationNone; } 68 int repetitionCount() const override { return cAnimationNone; }
72 virtual float frameDuration() const { return 0; } 69 float frameDuration() const override { return 0; }
73 70
74 protected: 71 protected:
75 void evictOneCache() 72 void evictOneCache()
76 { 73 {
77 size_t memoryUsageInBytes = ImageDecodingStore::instance().memoryUsageIn Bytes(); 74 size_t memoryUsageInBytes = ImageDecodingStore::instance().memoryUsageIn Bytes();
78 if (memoryUsageInBytes) 75 if (memoryUsageInBytes)
79 ImageDecodingStore::instance().setCacheLimitInBytes(memoryUsageInByt es - 1); 76 ImageDecodingStore::instance().setCacheLimitInBytes(memoryUsageInByt es - 1);
80 else 77 else
81 ImageDecodingStore::instance().setCacheLimitInBytes(0); 78 ImageDecodingStore::instance().setCacheLimitInBytes(0);
82 } 79 }
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after
172 ImageDecoder* testDecoder; 169 ImageDecoder* testDecoder;
173 EXPECT_TRUE(ImageDecodingStore::instance().lockDecoder(m_generator.get(), si ze, &testDecoder)); 170 EXPECT_TRUE(ImageDecodingStore::instance().lockDecoder(m_generator.get(), si ze, &testDecoder));
174 EXPECT_TRUE(testDecoder); 171 EXPECT_TRUE(testDecoder);
175 EXPECT_EQ(refDecoder, testDecoder); 172 EXPECT_EQ(refDecoder, testDecoder);
176 ImageDecodingStore::instance().removeDecoder(m_generator.get(), testDecoder) ; 173 ImageDecodingStore::instance().removeDecoder(m_generator.get(), testDecoder) ;
177 EXPECT_FALSE(ImageDecodingStore::instance().cacheEntries()); 174 EXPECT_FALSE(ImageDecodingStore::instance().cacheEntries());
178 175
179 EXPECT_FALSE(ImageDecodingStore::instance().lockDecoder(m_generator.get(), s ize, &testDecoder)); 176 EXPECT_FALSE(ImageDecodingStore::instance().lockDecoder(m_generator.get(), s ize, &testDecoder));
180 } 177 }
181 178
182 } // namespace 179 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698