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 "mojo/public/cpp/bindings/binding.h" | 9 #include "mojo/public/cpp/bindings/binding.h" |
10 #include "mojo/public/cpp/bindings/interface_request.h" | 10 #include "mojo/public/cpp/bindings/interface_request.h" |
11 #include "public/platform/modules/offscreencanvas/offscreen_canvas_surface.mojom
-blink.h" | 11 #include "public/platform/modules/offscreencanvas/offscreen_canvas_surface.mojom
-blink.h" |
12 #include "testing/gmock/include/gmock/gmock.h" | 12 #include "testing/gmock/include/gmock/gmock.h" |
13 #include "testing/gtest/include/gtest/gtest.h" | 13 #include "testing/gtest/include/gtest/gtest.h" |
14 #include "wtf/PtrUtil.h" | 14 #include "wtf/PtrUtil.h" |
15 #include <memory> | 15 #include <memory> |
16 #include <utility> | 16 #include <utility> |
17 | 17 |
18 namespace blink { | 18 namespace blink { |
19 | 19 |
20 //----------------------------------------------------------------------------- | 20 //----------------------------------------------------------------------------- |
21 | 21 |
22 class MockOffscreenCanvasSurface final | 22 class MockOffscreenCanvasSurface final |
23 : public mojom::blink::OffscreenCanvasSurface { | 23 : public mojom::blink::OffscreenCanvasSurface { |
24 public: | 24 public: |
25 MockOffscreenCanvasSurface(); | 25 MockOffscreenCanvasSurface(); |
26 ~MockOffscreenCanvasSurface() override; | 26 ~MockOffscreenCanvasSurface() override; |
27 | 27 |
28 mojom::blink::OffscreenCanvasSurfacePtr GetProxy(); | 28 mojom::blink::OffscreenCanvasSurfacePtr GetProxy(); |
29 | 29 |
30 void GetSurfaceId(GetSurfaceIdCallback) override; | 30 void GetSurfaceId(mojom::blink::OffscreenCanvasSurfaceClientPtr, |
| 31 GetSurfaceIdCallback) override; |
31 void Require(const cc::SurfaceId&, const cc::SurfaceSequence&) override {} | 32 void Require(const cc::SurfaceId&, const cc::SurfaceSequence&) override {} |
32 void Satisfy(const cc::SurfaceSequence&) override {} | 33 void Satisfy(const cc::SurfaceSequence&) override {} |
33 | 34 |
34 private: | 35 private: |
35 mojo::Binding<mojom::blink::OffscreenCanvasSurface> m_binding; | 36 mojo::Binding<mojom::blink::OffscreenCanvasSurface> m_binding; |
36 cc::SurfaceId m_surfaceId; | 37 cc::SurfaceId m_surfaceId; |
37 }; | 38 }; |
38 | 39 |
39 //----------------------------------------------------------------------------- | 40 //----------------------------------------------------------------------------- |
40 | 41 |
(...skipping 14 matching lines...) Expand all Loading... |
55 //----------------------------------------------------------------------------- | 56 //----------------------------------------------------------------------------- |
56 | 57 |
57 MockOffscreenCanvasSurface::MockOffscreenCanvasSurface() : m_binding(this) {} | 58 MockOffscreenCanvasSurface::MockOffscreenCanvasSurface() : m_binding(this) {} |
58 | 59 |
59 MockOffscreenCanvasSurface::~MockOffscreenCanvasSurface() {} | 60 MockOffscreenCanvasSurface::~MockOffscreenCanvasSurface() {} |
60 | 61 |
61 mojom::blink::OffscreenCanvasSurfacePtr MockOffscreenCanvasSurface::GetProxy() { | 62 mojom::blink::OffscreenCanvasSurfacePtr MockOffscreenCanvasSurface::GetProxy() { |
62 return m_binding.CreateInterfacePtrAndBind(); | 63 return m_binding.CreateInterfacePtrAndBind(); |
63 } | 64 } |
64 | 65 |
65 void MockOffscreenCanvasSurface::GetSurfaceId(GetSurfaceIdCallback callback) { | 66 void MockOffscreenCanvasSurface::GetSurfaceId( |
| 67 mojom::blink::OffscreenCanvasSurfaceClientPtr client, |
| 68 GetSurfaceIdCallback callback) { |
66 std::move(callback).Run( | 69 std::move(callback).Run( |
67 cc::SurfaceId(cc::FrameSinkId(10, 11), | 70 cc::SurfaceId(cc::FrameSinkId(10, 11), |
68 cc::LocalFrameId(15, base::UnguessableToken::Create()))); | 71 cc::LocalFrameId(15, base::UnguessableToken::Create()))); |
69 } | 72 } |
70 | 73 |
71 void CanvasSurfaceLayerBridgeTest::SetUp() { | 74 void CanvasSurfaceLayerBridgeTest::SetUp() { |
72 m_surfaceLayerBridge = | 75 m_surfaceLayerBridge = |
73 wrapUnique(new CanvasSurfaceLayerBridge(m_service.GetProxy())); | 76 wrapUnique(new CanvasSurfaceLayerBridge(m_service.GetProxy())); |
74 } | 77 } |
75 | 78 |
76 TEST_F(CanvasSurfaceLayerBridgeTest, SurfaceLayerCreation) { | 79 TEST_F(CanvasSurfaceLayerBridgeTest, SurfaceLayerCreation) { |
77 bool success = this->surfaceLayerBridge()->createSurfaceLayer(50, 50); | 80 bool success = this->surfaceLayerBridge()->createSurfaceLayer(50, 50); |
78 EXPECT_TRUE(success); | 81 EXPECT_TRUE(success); |
79 } | 82 } |
80 | 83 |
81 } // namespace blink | 84 } // namespace blink |
OLD | NEW |