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

Side by Side Diff: Source/platform/graphics/gpu/DrawingBufferTest.cpp

Issue 203513002: Move WebGraphicsContext3D related tests from web/tests/ to platform/graphics/gpu/ (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 6 years, 9 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
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 16 matching lines...) Expand all
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 32
33 #include "platform/graphics/gpu/DrawingBuffer.h" 33 #include "platform/graphics/gpu/DrawingBuffer.h"
34 34
35 #include "platform/graphics/ImageBuffer.h" 35 #include "platform/graphics/ImageBuffer.h"
36 #include "platform/graphics/UnacceleratedImageBufferSurface.h" 36 #include "platform/graphics/UnacceleratedImageBufferSurface.h"
37 #include "platform/graphics/test/MockWebGraphicsContext3D.h"
37 #include "public/platform/Platform.h" 38 #include "public/platform/Platform.h"
38 #include "public/platform/WebExternalTextureMailbox.h" 39 #include "public/platform/WebExternalTextureMailbox.h"
39 #include "web/tests/MockWebGraphicsContext3D.h"
40 #include "wtf/RefPtr.h" 40 #include "wtf/RefPtr.h"
41 41
42 #include <gmock/gmock.h> 42 #include <gmock/gmock.h>
43 #include <gtest/gtest.h> 43 #include <gtest/gtest.h>
44 44
45 using namespace WebCore; 45 using namespace WebCore;
46 using namespace blink; 46 using namespace blink;
47 using testing::Test; 47 using testing::Test;
48 using testing::_; 48 using testing::_;
49 49
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
98 WebGLId m_boundTexture; 98 WebGLId m_boundTexture;
99 HashMap<WebGLId, IntSize> m_textureSizes; 99 HashMap<WebGLId, IntSize> m_textureSizes;
100 WGC3Dbyte m_currentMailboxByte; 100 WGC3Dbyte m_currentMailboxByte;
101 IntSize m_mostRecentlyProducedSize; 101 IntSize m_mostRecentlyProducedSize;
102 }; 102 };
103 103
104 static const int initialWidth = 100; 104 static const int initialWidth = 100;
105 static const int initialHeight = 100; 105 static const int initialHeight = 100;
106 static const int alternateHeight = 50; 106 static const int alternateHeight = 50;
107 107
108 } // namespace
109
110 class DrawingBufferTest : public Test { 108 class DrawingBufferTest : public Test {
111 protected: 109 protected:
112 virtual void SetUp() 110 virtual void SetUp()
113 { 111 {
114 RefPtr<FakeContextEvictionManager> contextEvictionManager = adoptRef(new FakeContextEvictionManager()); 112 RefPtr<FakeContextEvictionManager> contextEvictionManager = adoptRef(new FakeContextEvictionManager());
115 m_context = adoptPtr(new WebGraphicsContext3DForTests); 113 m_context = adoptPtr(new WebGraphicsContext3DForTests);
116 m_drawingBuffer = DrawingBuffer::create(m_context.get(), IntSize(initial Width, initialHeight), DrawingBuffer::Preserve, contextEvictionManager.release() ); 114 m_drawingBuffer = DrawingBuffer::create(m_context.get(), IntSize(initial Width, initialHeight), DrawingBuffer::Preserve, contextEvictionManager.release() );
117 } 115 }
118 116
119 WebGraphicsContext3DForTests* webContext() 117 WebGraphicsContext3DForTests* webContext()
120 { 118 {
121 return m_context.get(); 119 return m_context.get();
122 } 120 }
123 121
124 OwnPtr<WebGraphicsContext3DForTests> m_context; 122 OwnPtr<WebGraphicsContext3DForTests> m_context;
125 RefPtr<DrawingBuffer> m_drawingBuffer; 123 RefPtr<DrawingBuffer> m_drawingBuffer;
126 }; 124 };
127 125
128 namespace {
129
130 TEST_F(DrawingBufferTest, testPaintRenderingResultsToCanvas) 126 TEST_F(DrawingBufferTest, testPaintRenderingResultsToCanvas)
131 { 127 {
132 OwnPtr<ImageBufferSurface> imageBufferSurface = adoptPtr(new UnacceleratedIm ageBufferSurface(IntSize(initialWidth, initialHeight))); 128 OwnPtr<ImageBufferSurface> imageBufferSurface = adoptPtr(new UnacceleratedIm ageBufferSurface(IntSize(initialWidth, initialHeight)));
133 EXPECT_FALSE(!imageBufferSurface); 129 EXPECT_FALSE(!imageBufferSurface);
134 EXPECT_TRUE(imageBufferSurface->isValid()); 130 EXPECT_TRUE(imageBufferSurface->isValid());
135 OwnPtr<ImageBuffer> imageBuffer = ImageBuffer::create(imageBufferSurface.rel ease()); 131 OwnPtr<ImageBuffer> imageBuffer = ImageBuffer::create(imageBufferSurface.rel ease());
136 EXPECT_FALSE(!imageBuffer); 132 EXPECT_FALSE(!imageBuffer);
137 EXPECT_FALSE(imageBuffer->isAccelerated()); 133 EXPECT_FALSE(imageBuffer->isAccelerated());
138 EXPECT_FALSE(imageBuffer->bitmap().isNull()); 134 EXPECT_FALSE(imageBuffer->bitmap().isNull());
139 m_drawingBuffer->paintRenderingResultsToCanvas(imageBuffer.get()); 135 m_drawingBuffer->paintRenderingResultsToCanvas(imageBuffer.get());
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after
238 EXPECT_TRUE(m_drawingBuffer->prepareMailbox(&recycledMailbox, 0)); 234 EXPECT_TRUE(m_drawingBuffer->prepareMailbox(&recycledMailbox, 0));
239 EXPECT_EQ(TextureMailboxWrapper(mailbox3), TextureMailboxWrapper(recycledMai lbox)); 235 EXPECT_EQ(TextureMailboxWrapper(mailbox3), TextureMailboxWrapper(recycledMai lbox));
240 236
241 // The third recycled mailbox must be 1. 237 // The third recycled mailbox must be 1.
242 m_drawingBuffer->markContentsChanged(); 238 m_drawingBuffer->markContentsChanged();
243 EXPECT_TRUE(m_drawingBuffer->prepareMailbox(&recycledMailbox, 0)); 239 EXPECT_TRUE(m_drawingBuffer->prepareMailbox(&recycledMailbox, 0));
244 EXPECT_EQ(TextureMailboxWrapper(mailbox1), TextureMailboxWrapper(recycledMai lbox)); 240 EXPECT_EQ(TextureMailboxWrapper(mailbox1), TextureMailboxWrapper(recycledMai lbox));
245 } 241 }
246 242
247 } // namespace 243 } // namespace
OLDNEW
« no previous file with comments | « Source/platform/graphics/Canvas2DLayerManagerTest.cpp ('k') | Source/platform/graphics/test/MockWebGraphicsContext3D.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698