| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "platform/graphics/CanvasSurfaceLayerBridge.h" | 5 #include "platform/graphics/CanvasSurfaceLayerBridge.h" |
| 6 | 6 |
| 7 #include "cc/surfaces/surface_id.h" | 7 #include "cc/surfaces/surface_id.h" |
| 8 #include "cc/surfaces/surface_sequence.h" | 8 #include "cc/surfaces/surface_sequence.h" |
| 9 #include "platform/graphics/CanvasSurfaceLayerBridgeClient.h" | 9 #include "platform/graphics/CanvasSurfaceLayerBridgeClient.h" |
| 10 #include "testing/gmock/include/gmock/gmock.h" | 10 #include "testing/gmock/include/gmock/gmock.h" |
| (...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 82 m_service->RequestSurfaceCreation(surfaceId); | 82 m_service->RequestSurfaceCreation(surfaceId); |
| 83 } | 83 } |
| 84 | 84 |
| 85 FakeOffscreenCanvasSurfaceImpl::~FakeOffscreenCanvasSurfaceImpl() | 85 FakeOffscreenCanvasSurfaceImpl::~FakeOffscreenCanvasSurfaceImpl() |
| 86 { | 86 { |
| 87 m_fakeSurfaceMap.clear(); | 87 m_fakeSurfaceMap.clear(); |
| 88 } | 88 } |
| 89 | 89 |
| 90 bool FakeOffscreenCanvasSurfaceImpl::GetSurfaceId(cc::SurfaceId* surfaceId) | 90 bool FakeOffscreenCanvasSurfaceImpl::GetSurfaceId(cc::SurfaceId* surfaceId) |
| 91 { | 91 { |
| 92 *surfaceId = cc::SurfaceId(10, 15, 0); | 92 *surfaceId = cc::SurfaceId(0, 10, 15, 0); |
| 93 return true; | 93 return true; |
| 94 } | 94 } |
| 95 | 95 |
| 96 void FakeOffscreenCanvasSurfaceImpl::RequestSurfaceCreation(const cc::SurfaceId&
surfaceId) | 96 void FakeOffscreenCanvasSurfaceImpl::RequestSurfaceCreation(const cc::SurfaceId&
surfaceId) |
| 97 { | 97 { |
| 98 m_fakeSurfaceMap.append(surfaceId); | 98 m_fakeSurfaceMap.append(surfaceId); |
| 99 } | 99 } |
| 100 | 100 |
| 101 bool FakeOffscreenCanvasSurfaceImpl::isSurfaceInSurfaceMap(const cc::SurfaceId&
surfaceId) | 101 bool FakeOffscreenCanvasSurfaceImpl::isSurfaceInSurfaceMap(const cc::SurfaceId&
surfaceId) |
| 102 { | 102 { |
| 103 return m_fakeSurfaceMap.contains(surfaceId); | 103 return m_fakeSurfaceMap.contains(surfaceId); |
| 104 } | 104 } |
| 105 | 105 |
| 106 void CanvasSurfaceLayerBridgeTest::SetUp() | 106 void CanvasSurfaceLayerBridgeTest::SetUp() |
| 107 { | 107 { |
| 108 m_surfaceService = wrapUnique(new FakeOffscreenCanvasSurfaceImpl()); | 108 m_surfaceService = wrapUnique(new FakeOffscreenCanvasSurfaceImpl()); |
| 109 std::unique_ptr<CanvasSurfaceLayerBridgeClient> bridgeClient = wrapUnique(ne
w MockCanvasSurfaceLayerBridgeClient(m_surfaceService.get())); | 109 std::unique_ptr<CanvasSurfaceLayerBridgeClient> bridgeClient = wrapUnique(ne
w MockCanvasSurfaceLayerBridgeClient(m_surfaceService.get())); |
| 110 m_surfaceLayerBridge = wrapUnique(new CanvasSurfaceLayerBridge(std::move(bri
dgeClient))); | 110 m_surfaceLayerBridge = wrapUnique(new CanvasSurfaceLayerBridge(std::move(bri
dgeClient))); |
| 111 } | 111 } |
| 112 | 112 |
| 113 TEST_F(CanvasSurfaceLayerBridgeTest, SurfaceLayerCreation) | 113 TEST_F(CanvasSurfaceLayerBridgeTest, SurfaceLayerCreation) |
| 114 { | 114 { |
| 115 bool success = this->surfaceLayerBridge()->createSurfaceLayer(50, 50); | 115 bool success = this->surfaceLayerBridge()->createSurfaceLayer(50, 50); |
| 116 EXPECT_TRUE(this->surfaceService()->isSurfaceInSurfaceMap(this->surfaceLayer
Bridge()->getSurfaceId())); | 116 EXPECT_TRUE(this->surfaceService()->isSurfaceInSurfaceMap(this->surfaceLayer
Bridge()->getSurfaceId())); |
| 117 EXPECT_TRUE(success); | 117 EXPECT_TRUE(success); |
| 118 } | 118 } |
| 119 | 119 |
| 120 } // namespace blink | 120 } // namespace blink |
| OLD | NEW |