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

Side by Side Diff: Source/platform/graphics/ImageLayerChromiumTest.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) 2011 Google Inc. All rights reserved. 2 * Copyright (C) 2011 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 * 1. Redistributions of source code must retain the above copyright 7 * 1. Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer. 8 * notice, this list of conditions and the following disclaimer.
9 * 2. Redistributions in binary form must reproduce the above copyright 9 * 2. Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the 10 * notice, this list of conditions and the following disclaimer in the
11 * documentation and/or other materials provided with the distribution. 11 * documentation and/or other materials provided with the distribution.
12 * 12 *
13 * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' AND AN Y 13 * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS'' AND AN Y
14 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 14 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
15 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 15 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
16 * DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS BE LIABLE FOR AN Y 16 * DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS BE LIABLE FOR AN Y
17 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 17 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
18 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 18 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
19 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND O N 19 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND O N
20 * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 20 * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
21 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 21 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
22 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 22 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
23 */ 23 */
24 24
25 #include "config.h" 25 #include "config.h"
26 #include "platform/graphics/Image.h" 26 #include "platform/graphics/Image.h"
27 27
28 #include "platform/graphics/GraphicsLayer.h" 28 #include "platform/graphics/GraphicsLayer.h"
29 #include "wtf/PassOwnPtr.h" 29 #include "wtf/PassOwnPtr.h"
30
31 #include <gtest/gtest.h> 30 #include <gtest/gtest.h>
32 31
33 using namespace blink; 32 namespace blink {
34 33
35 namespace { 34 namespace {
36 35
37 class MockGraphicsLayerClient : public GraphicsLayerClient { 36 class MockGraphicsLayerClient : public GraphicsLayerClient {
38 public: 37 public:
39 virtual void paintContents(const GraphicsLayer*, GraphicsContext&, GraphicsL ayerPaintingPhase, const IntRect& inClip) override { } 38 void paintContents(const GraphicsLayer*, GraphicsContext&, GraphicsLayerPain tingPhase, const IntRect&) override { }
40 virtual String debugName(const GraphicsLayer*) override { return String(); } 39 String debugName(const GraphicsLayer*) override { return String(); }
41 }; 40 };
42 41
43 class TestImage : public Image { 42 class TestImage : public Image {
44 public: 43 public:
45
46 static PassRefPtr<TestImage> create(const IntSize& size, bool isOpaque) 44 static PassRefPtr<TestImage> create(const IntSize& size, bool isOpaque)
47 { 45 {
48 return adoptRef(new TestImage(size, isOpaque)); 46 return adoptRef(new TestImage(size, isOpaque));
49 } 47 }
50 48
51 explicit TestImage(const IntSize& size, bool isOpaque) 49 TestImage(const IntSize& size, bool isOpaque)
52 : Image(0) 50 : Image(0)
53 , m_size(size) 51 , m_size(size)
54 { 52 {
55 m_bitmap.allocN32Pixels(size.width(), size.height(), isOpaque); 53 m_bitmap.allocN32Pixels(size.width(), size.height(), isOpaque);
56 m_bitmap.eraseColor(SK_ColorTRANSPARENT); 54 m_bitmap.eraseColor(SK_ColorTRANSPARENT);
57 } 55 }
58 56
59 virtual bool isBitmapImage() const override 57 bool isBitmapImage() const override
60 { 58 {
61 return true; 59 return true;
62 } 60 }
63 61
64 virtual bool currentFrameKnownToBeOpaque() override 62 bool currentFrameKnownToBeOpaque() override
65 { 63 {
66 return m_bitmap.isOpaque(); 64 return m_bitmap.isOpaque();
67 } 65 }
68 66
69 virtual IntSize size() const override 67 IntSize size() const override
70 { 68 {
71 return m_size; 69 return m_size;
72 } 70 }
73 71
74 virtual bool bitmapForCurrentFrame(SkBitmap* bitmap) override 72 bool bitmapForCurrentFrame(SkBitmap* bitmap) override
75 { 73 {
76 if (m_size.isZero()) 74 if (m_size.isZero())
77 return false; 75 return false;
78 76
79 *bitmap = m_bitmap; 77 *bitmap = m_bitmap;
80 return true; 78 return true;
81 } 79 }
82 80
83 // Stub implementations of pure virtual Image functions. 81 // Stub implementations of pure virtual Image functions.
84 virtual void destroyDecodedData(bool) override 82 void destroyDecodedData(bool) override
85 { 83 {
86 } 84 }
87 85
88 void draw(SkCanvas*, const SkPaint&, const FloatRect&, const FloatRect&, Res pectImageOrientationEnum, ImageClampingMode) override 86 void draw(SkCanvas*, const SkPaint&, const FloatRect&, const FloatRect&, Res pectImageOrientationEnum, ImageClampingMode) override
89 { 87 {
90 } 88 }
91 89
92 private: 90 private:
93
94 IntSize m_size; 91 IntSize m_size;
95
96 SkBitmap m_bitmap; 92 SkBitmap m_bitmap;
97 }; 93 };
98 94
99 class GraphicsLayerForTesting : public GraphicsLayer { 95 class GraphicsLayerForTesting : public GraphicsLayer {
100 public: 96 public:
101 explicit GraphicsLayerForTesting(GraphicsLayerClient* client) 97 explicit GraphicsLayerForTesting(GraphicsLayerClient* client)
102 : GraphicsLayer(client) { }; 98 : GraphicsLayer(client) { };
103 99
104 virtual WebLayer* contentsLayer() const { return GraphicsLayer::contentsLaye r(); } 100 WebLayer* contentsLayer() const { return GraphicsLayer::contentsLayer(); }
105 }; 101 };
106 102
103 } // anonymous namespace
104
107 TEST(ImageLayerChromiumTest, imageLayerContentReset) 105 TEST(ImageLayerChromiumTest, imageLayerContentReset)
108 { 106 {
109 MockGraphicsLayerClient client; 107 MockGraphicsLayerClient client;
110 OwnPtr<GraphicsLayerForTesting> graphicsLayer = adoptPtr(new GraphicsLayerFo rTesting(&client)); 108 OwnPtr<GraphicsLayerForTesting> graphicsLayer = adoptPtr(new GraphicsLayerFo rTesting(&client));
111 ASSERT_TRUE(graphicsLayer.get()); 109 ASSERT_TRUE(graphicsLayer.get());
112 110
113 ASSERT_FALSE(graphicsLayer->hasContentsLayer()); 111 ASSERT_FALSE(graphicsLayer->hasContentsLayer());
114 ASSERT_FALSE(graphicsLayer->contentsLayer()); 112 ASSERT_FALSE(graphicsLayer->contentsLayer());
115 113
116 RefPtr<Image> image = TestImage::create(IntSize(100, 100), false); 114 RefPtr<Image> image = TestImage::create(IntSize(100, 100), false);
(...skipping 21 matching lines...) Expand all
138 136
139 ASSERT_FALSE(graphicsLayer->contentsLayer()); 137 ASSERT_FALSE(graphicsLayer->contentsLayer());
140 138
141 graphicsLayer->setContentsToImage(opaqueImage.get()); 139 graphicsLayer->setContentsToImage(opaqueImage.get());
142 ASSERT_TRUE(graphicsLayer->contentsLayer()->opaque()); 140 ASSERT_TRUE(graphicsLayer->contentsLayer()->opaque());
143 141
144 graphicsLayer->setContentsToImage(nonOpaqueImage.get()); 142 graphicsLayer->setContentsToImage(nonOpaqueImage.get());
145 ASSERT_FALSE(graphicsLayer->contentsLayer()->opaque()); 143 ASSERT_FALSE(graphicsLayer->contentsLayer()->opaque());
146 } 144 }
147 145
148 } // namespace 146 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698