OLD | NEW |
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 12 matching lines...) Expand all Loading... |
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 | 32 |
33 #include "core/platform/graphics/gpu/DrawingBuffer.h" | 33 #include "platform/graphics/gpu/DrawingBuffer.h" |
34 | 34 |
35 #include "core/platform/graphics/GraphicsContext3D.h" | 35 #include "platform/graphics/GraphicsContext3D.h" |
36 #include "core/platform/testing/FakeWebGraphicsContext3D.h" | |
37 #include "public/platform/Platform.h" | 36 #include "public/platform/Platform.h" |
| 37 #include "web/tests/MockWebGraphicsContext3D.h" |
38 #include "wtf/RefPtr.h" | 38 #include "wtf/RefPtr.h" |
39 | 39 |
40 #include <gmock/gmock.h> | 40 #include <gmock/gmock.h> |
41 #include <gtest/gtest.h> | 41 #include <gtest/gtest.h> |
42 | 42 |
43 using namespace WebCore; | 43 using namespace WebCore; |
44 using namespace blink; | 44 using namespace blink; |
45 using testing::Test; | 45 using testing::Test; |
46 using testing::_; | 46 using testing::_; |
47 | 47 |
48 namespace { | 48 namespace { |
49 | 49 |
50 class FakeContextEvictionManager : public ContextEvictionManager { | 50 class FakeContextEvictionManager : public ContextEvictionManager { |
51 public: | 51 public: |
52 void forciblyLoseOldestContext(const String& reason) { } | 52 void forciblyLoseOldestContext(const String& reason) { } |
53 IntSize oldestContextSize() { return IntSize(); } | 53 IntSize oldestContextSize() { return IntSize(); } |
54 }; | 54 }; |
55 | 55 |
56 } // namespace | 56 } // namespace |
57 | 57 |
58 class DrawingBufferTest : public Test { | 58 class DrawingBufferTest : public Test { |
59 protected: | 59 protected: |
60 virtual void SetUp() | 60 virtual void SetUp() |
61 { | 61 { |
62 RefPtr<FakeContextEvictionManager> contextEvictionManager = adoptRef(new
FakeContextEvictionManager()); | 62 RefPtr<FakeContextEvictionManager> contextEvictionManager = adoptRef(new
FakeContextEvictionManager()); |
63 RefPtr<GraphicsContext3D> context = GraphicsContext3D::createGraphicsCon
textFromWebContext(adoptPtr(new FakeWebGraphicsContext3D)); | 63 RefPtr<GraphicsContext3D> context = GraphicsContext3D::createGraphicsCon
textFromWebContext(adoptPtr(new MockWebGraphicsContext3D)); |
64 const IntSize size(100, 100); | 64 const IntSize size(100, 100); |
65 m_drawingBuffer = DrawingBuffer::create(context.get(), size, DrawingBuff
er::Discard, contextEvictionManager.release()); | 65 m_drawingBuffer = DrawingBuffer::create(context.get(), size, DrawingBuff
er::Discard, contextEvictionManager.release()); |
66 } | 66 } |
67 | 67 |
68 RefPtr<DrawingBuffer> m_drawingBuffer; | 68 RefPtr<DrawingBuffer> m_drawingBuffer; |
69 }; | 69 }; |
70 | 70 |
71 namespace { | 71 namespace { |
72 | 72 |
73 TEST_F(DrawingBufferTest, verifyNoNewBuffersAfterContextLostWithMailboxes) | 73 TEST_F(DrawingBufferTest, verifyNoNewBuffersAfterContextLostWithMailboxes) |
74 { | 74 { |
75 // Tell the buffer its contents changed and context was lost. | 75 // Tell the buffer its contents changed and context was lost. |
76 m_drawingBuffer->markContentsChanged(); | 76 m_drawingBuffer->markContentsChanged(); |
77 m_drawingBuffer->releaseResources(); | 77 m_drawingBuffer->releaseResources(); |
78 | 78 |
79 blink::WebExternalTextureMailbox mailbox; | 79 blink::WebExternalTextureMailbox mailbox; |
80 EXPECT_FALSE(m_drawingBuffer->prepareMailbox(&mailbox, 0)); | 80 EXPECT_FALSE(m_drawingBuffer->prepareMailbox(&mailbox, 0)); |
81 } | 81 } |
82 | 82 |
83 } // namespace | 83 } // namespace |
OLD | NEW |