OLD | NEW |
---|---|
1 // Copyright (c) 2016 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 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 "base/message_loop/message_loop.h" | 5 #include "base/message_loop/message_loop.h" |
6 #include "content/browser/compositor/test/no_transport_image_transport_factory.h " | 6 #include "content/browser/compositor/test/no_transport_image_transport_factory.h " |
7 #include "content/browser/renderer_host/offscreen_canvas_surface_impl.h" | 7 #include "content/browser/renderer_host/offscreen_canvas_surface_impl.h" |
8 #include "content/browser/renderer_host/offscreen_canvas_surface_manager.h" | 8 #include "content/browser/renderer_host/offscreen_canvas_surface_manager.h" |
9 #include "content/public/test/test_browser_thread.h" | 9 #include "content/public/test/test_browser_thread.h" |
10 #include "mojo/public/cpp/bindings/binding.h" | 10 #include "mojo/public/cpp/bindings/binding.h" |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
65 ImageTransportFactory::Terminate(); | 65 ImageTransportFactory::Terminate(); |
66 #endif | 66 #endif |
67 } | 67 } |
68 | 68 |
69 // This test mimics the workflow of OffscreenCanvas.commit() on renderer | 69 // This test mimics the workflow of OffscreenCanvas.commit() on renderer |
70 // process. | 70 // process. |
71 TEST_F(OffscreenCanvasSurfaceManagerTest, | 71 TEST_F(OffscreenCanvasSurfaceManagerTest, |
72 SingleHTMLCanvasElementTransferToOffscreen) { | 72 SingleHTMLCanvasElementTransferToOffscreen) { |
73 cc::mojom::DisplayCompositorClientPtr client; | 73 cc::mojom::DisplayCompositorClientPtr client; |
74 cc::FrameSinkId frame_sink_id(3, 3); | 74 cc::FrameSinkId frame_sink_id(3, 3); |
75 cc::SurfaceIdAllocator surface_id_allocator; | 75 cc::LocalSurfaceIdAllocator local_surface_id_allocator; |
76 cc::LocalSurfaceId current_local_surface_id( | 76 cc::LocalSurfaceId current_local_surface_id( |
77 surface_id_allocator.GenerateId()); | 77 local_surface_id_allocator.GenerateId()); |
78 | 78 |
79 auto surface_impl = base::WrapUnique(new OffscreenCanvasSurfaceImpl( | 79 auto surface_impl = base::WrapUnique(new OffscreenCanvasSurfaceImpl( |
80 cc::FrameSinkId(), frame_sink_id, std::move(client))); | 80 cc::FrameSinkId(), frame_sink_id, std::move(client))); |
81 EXPECT_EQ(1, this->getNumSurfaceImplInstances()); | 81 EXPECT_EQ(1, this->getNumSurfaceImplInstances()); |
82 EXPECT_EQ(surface_impl.get(), | 82 EXPECT_EQ(surface_impl.get(), |
83 OffscreenCanvasSurfaceManager::GetInstance()->GetSurfaceInstance( | 83 OffscreenCanvasSurfaceManager::GetInstance()->GetSurfaceInstance( |
84 frame_sink_id)); | 84 frame_sink_id)); |
85 | 85 |
86 this->OnSurfaceCreated( | 86 this->OnSurfaceCreated( |
87 cc::SurfaceId(frame_sink_id, current_local_surface_id)); | 87 cc::SurfaceId(frame_sink_id, current_local_surface_id)); |
88 EXPECT_EQ(current_local_surface_id, surface_impl->current_local_surface_id()); | 88 EXPECT_EQ(current_local_surface_id, surface_impl->current_local_surface_id()); |
89 | 89 |
90 surface_impl = nullptr; | 90 surface_impl = nullptr; |
91 EXPECT_EQ(0, this->getNumSurfaceImplInstances()); | 91 EXPECT_EQ(0, this->getNumSurfaceImplInstances()); |
92 } | 92 } |
93 | 93 |
94 TEST_F(OffscreenCanvasSurfaceManagerTest, | 94 TEST_F(OffscreenCanvasSurfaceManagerTest, |
95 MultiHTMLCanvasElementTransferToOffscreen) { | 95 MultiHTMLCanvasElementTransferToOffscreen) { |
96 cc::mojom::DisplayCompositorClientPtr client_a; | 96 cc::mojom::DisplayCompositorClientPtr client_a; |
97 cc::FrameSinkId dummy_parent_frame_sink_id(0, 0); | 97 cc::FrameSinkId dummy_parent_frame_sink_id(0, 0); |
98 cc::FrameSinkId frame_sink_id_a(3, 3); | 98 cc::FrameSinkId frame_sink_id_a(3, 3); |
99 cc::SurfaceIdAllocator surface_id_allocator; | 99 cc::LocalSurfaceIdAllocator local_surface_id_allocator; |
boliu
2017/02/22 17:09:15
remove
| |
100 auto surface_impl_a = base::WrapUnique(new OffscreenCanvasSurfaceImpl( | 100 auto surface_impl_a = base::WrapUnique(new OffscreenCanvasSurfaceImpl( |
101 dummy_parent_frame_sink_id, frame_sink_id_a, std::move(client_a))); | 101 dummy_parent_frame_sink_id, frame_sink_id_a, std::move(client_a))); |
102 | 102 |
103 cc::mojom::DisplayCompositorClientPtr client_b; | 103 cc::mojom::DisplayCompositorClientPtr client_b; |
104 cc::FrameSinkId frame_sink_id_b(4, 4); | 104 cc::FrameSinkId frame_sink_id_b(4, 4); |
105 | 105 |
106 auto surface_impl_b = base::WrapUnique(new OffscreenCanvasSurfaceImpl( | 106 auto surface_impl_b = base::WrapUnique(new OffscreenCanvasSurfaceImpl( |
107 dummy_parent_frame_sink_id, frame_sink_id_b, std::move(client_b))); | 107 dummy_parent_frame_sink_id, frame_sink_id_b, std::move(client_b))); |
108 | 108 |
109 EXPECT_EQ(2, this->getNumSurfaceImplInstances()); | 109 EXPECT_EQ(2, this->getNumSurfaceImplInstances()); |
110 EXPECT_EQ(surface_impl_a.get(), | 110 EXPECT_EQ(surface_impl_a.get(), |
111 OffscreenCanvasSurfaceManager::GetInstance()->GetSurfaceInstance( | 111 OffscreenCanvasSurfaceManager::GetInstance()->GetSurfaceInstance( |
112 frame_sink_id_a)); | 112 frame_sink_id_a)); |
113 EXPECT_EQ(surface_impl_b.get(), | 113 EXPECT_EQ(surface_impl_b.get(), |
114 OffscreenCanvasSurfaceManager::GetInstance()->GetSurfaceInstance( | 114 OffscreenCanvasSurfaceManager::GetInstance()->GetSurfaceInstance( |
115 frame_sink_id_b)); | 115 frame_sink_id_b)); |
116 | 116 |
117 surface_impl_a = nullptr; | 117 surface_impl_a = nullptr; |
118 EXPECT_EQ(1, this->getNumSurfaceImplInstances()); | 118 EXPECT_EQ(1, this->getNumSurfaceImplInstances()); |
119 surface_impl_b = nullptr; | 119 surface_impl_b = nullptr; |
120 EXPECT_EQ(0, this->getNumSurfaceImplInstances()); | 120 EXPECT_EQ(0, this->getNumSurfaceImplInstances()); |
121 } | 121 } |
122 | 122 |
123 } // namespace content | 123 } // namespace content |
OLD | NEW |