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

Side by Side Diff: third_party/WebKit/Source/platform/graphics/CanvasSurfaceLayerBridgeTest.cpp

Issue 2584643002: Revamp OffscreenCanvas commit flow (Closed)
Patch Set: rebase and fix conflict Created 4 years 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
(Empty)
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
3 // found in the LICENSE file.
4
5 #include "platform/graphics/CanvasSurfaceLayerBridge.h"
6
7 #include "cc/surfaces/surface_id.h"
8 #include "cc/surfaces/surface_sequence.h"
9 #include "mojo/public/cpp/bindings/binding.h"
10 #include "mojo/public/cpp/bindings/interface_request.h"
11 #include "public/platform/modules/offscreencanvas/offscreen_canvas_surface.mojom -blink.h"
12 #include "testing/gmock/include/gmock/gmock.h"
13 #include "testing/gtest/include/gtest/gtest.h"
14 #include "wtf/PtrUtil.h"
15 #include <memory>
16 #include <utility>
17
18 namespace blink {
19
20 //-----------------------------------------------------------------------------
21
22 class MockOffscreenCanvasSurface final
23 : public mojom::blink::OffscreenCanvasSurface {
24 public:
25 MockOffscreenCanvasSurface();
26 ~MockOffscreenCanvasSurface() override;
27
28 mojom::blink::OffscreenCanvasSurfacePtr GetProxy();
29
30 void GetSurfaceId(GetSurfaceIdCallback) override;
31 void Require(const cc::SurfaceId&, const cc::SurfaceSequence&) override {}
32 void Satisfy(const cc::SurfaceSequence&) override {}
33
34 private:
35 mojo::Binding<mojom::blink::OffscreenCanvasSurface> m_binding;
36 cc::SurfaceId m_surfaceId;
37 };
38
39 //-----------------------------------------------------------------------------
40
41 class CanvasSurfaceLayerBridgeTest : public testing::Test {
42 public:
43 CanvasSurfaceLayerBridge* surfaceLayerBridge() const {
44 return m_surfaceLayerBridge.get();
45 }
46
47 protected:
48 void SetUp() override;
49
50 private:
51 MockOffscreenCanvasSurface m_service;
52 std::unique_ptr<CanvasSurfaceLayerBridge> m_surfaceLayerBridge;
53 };
54
55 //-----------------------------------------------------------------------------
56
57 MockOffscreenCanvasSurface::MockOffscreenCanvasSurface() : m_binding(this) {}
58
59 MockOffscreenCanvasSurface::~MockOffscreenCanvasSurface() {}
60
61 mojom::blink::OffscreenCanvasSurfacePtr MockOffscreenCanvasSurface::GetProxy() {
62 return m_binding.CreateInterfacePtrAndBind();
63 }
64
65 void MockOffscreenCanvasSurface::GetSurfaceId(GetSurfaceIdCallback callback) {
66 std::move(callback).Run(
67 cc::SurfaceId(cc::FrameSinkId(10, 11),
68 cc::LocalFrameId(15, base::UnguessableToken::Create())));
69 }
70
71 void CanvasSurfaceLayerBridgeTest::SetUp() {
72 m_surfaceLayerBridge =
73 WTF::wrapUnique(new CanvasSurfaceLayerBridge(m_service.GetProxy()));
74 }
75
76 TEST_F(CanvasSurfaceLayerBridgeTest, SurfaceLayerCreation) {
77 bool success = this->surfaceLayerBridge()->createSurfaceLayer(50, 50);
78 EXPECT_TRUE(success);
79 }
80
81 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698