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

Side by Side Diff: components/exo/surface_unittest.cc

Issue 2493223002: Change exo::SurfaceFactoryOwner to exo::ExoCompositorFrameSink (Closed)
Patch Set: Override DesktopMediaListAshTest::TearDown() to reset list_ 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
« no previous file with comments | « components/exo/surface.cc ('k') | components/exo/test/run_all_unittests.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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/bind.h" 5 #include "base/bind.h"
6 #include "cc/output/compositor_frame.h" 6 #include "cc/output/compositor_frame.h"
7 #include "cc/quads/texture_draw_quad.h" 7 #include "cc/quads/texture_draw_quad.h"
8 #include "cc/surfaces/surface.h" 8 #include "cc/surfaces/surface.h"
9 #include "cc/surfaces/surface_manager.h" 9 #include "cc/surfaces/surface_manager.h"
10 #include "components/exo/buffer.h" 10 #include "components/exo/buffer.h"
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
43 surface->Commit(); 43 surface->Commit();
44 44
45 // Commit without calling Attach() should have no effect. 45 // Commit without calling Attach() should have no effect.
46 surface->Commit(); 46 surface->Commit();
47 EXPECT_EQ(0, release_buffer_call_count); 47 EXPECT_EQ(0, release_buffer_call_count);
48 48
49 // Attach a null buffer to surface, this should release the previously 49 // Attach a null buffer to surface, this should release the previously
50 // attached buffer. 50 // attached buffer.
51 surface->Attach(nullptr); 51 surface->Attach(nullptr);
52 surface->Commit(); 52 surface->Commit();
53 // CompositorFrameSinkHolder::ReclaimResources() gets called via
54 // MojoCompositorFrameSinkClient interface. We need to wait here for the mojo
55 // call to finish so that the release callback finishes running before
56 // the assertion below.
57 RunAllPendingInMessageLoop();
53 ASSERT_EQ(1, release_buffer_call_count); 58 ASSERT_EQ(1, release_buffer_call_count);
54 } 59 }
55 60
56 TEST_F(SurfaceTest, Damage) { 61 TEST_F(SurfaceTest, Damage) {
57 gfx::Size buffer_size(256, 256); 62 gfx::Size buffer_size(256, 256);
58 std::unique_ptr<Buffer> buffer( 63 std::unique_ptr<Buffer> buffer(
59 new Buffer(exo_test_helper()->CreateGpuMemoryBuffer(buffer_size))); 64 new Buffer(exo_test_helper()->CreateGpuMemoryBuffer(buffer_size)));
60 std::unique_ptr<Surface> surface(new Surface); 65 std::unique_ptr<Surface> surface(new Surface);
61 66
62 // Attach the buffer to the surface. This will update the pending bounds of 67 // Attach the buffer to the surface. This will update the pending bounds of
(...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after
198 203
199 TEST_F(SurfaceTest, SetBlendMode) { 204 TEST_F(SurfaceTest, SetBlendMode) {
200 gfx::Size buffer_size(1, 1); 205 gfx::Size buffer_size(1, 1);
201 std::unique_ptr<Buffer> buffer( 206 std::unique_ptr<Buffer> buffer(
202 new Buffer(exo_test_helper()->CreateGpuMemoryBuffer(buffer_size))); 207 new Buffer(exo_test_helper()->CreateGpuMemoryBuffer(buffer_size)));
203 std::unique_ptr<Surface> surface(new Surface); 208 std::unique_ptr<Surface> surface(new Surface);
204 209
205 surface->Attach(buffer.get()); 210 surface->Attach(buffer.get());
206 surface->SetBlendMode(SkBlendMode::kSrc); 211 surface->SetBlendMode(SkBlendMode::kSrc);
207 surface->Commit(); 212 surface->Commit();
213 RunAllPendingInMessageLoop();
208 214
209 const cc::CompositorFrame& frame = GetFrameFromSurface(surface.get()); 215 const cc::CompositorFrame& frame = GetFrameFromSurface(surface.get());
210 ASSERT_EQ(1u, frame.render_pass_list.size()); 216 ASSERT_EQ(1u, frame.render_pass_list.size());
211 ASSERT_EQ(1u, frame.render_pass_list.back()->quad_list.size()); 217 ASSERT_EQ(1u, frame.render_pass_list.back()->quad_list.size());
212 EXPECT_FALSE(frame.render_pass_list.back() 218 EXPECT_FALSE(frame.render_pass_list.back()
213 ->quad_list.back() 219 ->quad_list.back()
214 ->ShouldDrawWithBlending()); 220 ->ShouldDrawWithBlending());
215 } 221 }
216 222
217 TEST_F(SurfaceTest, OverlayCandidate) { 223 TEST_F(SurfaceTest, OverlayCandidate) {
218 gfx::Size buffer_size(1, 1); 224 gfx::Size buffer_size(1, 1);
219 std::unique_ptr<Buffer> buffer(new Buffer( 225 std::unique_ptr<Buffer> buffer(new Buffer(
220 exo_test_helper()->CreateGpuMemoryBuffer(buffer_size), 0, 0, true, true)); 226 exo_test_helper()->CreateGpuMemoryBuffer(buffer_size), 0, 0, true, true));
221 std::unique_ptr<Surface> surface(new Surface); 227 std::unique_ptr<Surface> surface(new Surface);
222 228
223 surface->Attach(buffer.get()); 229 surface->Attach(buffer.get());
224 surface->Commit(); 230 surface->Commit();
231 RunAllPendingInMessageLoop();
225 232
226 const cc::CompositorFrame& frame = GetFrameFromSurface(surface.get()); 233 const cc::CompositorFrame& frame = GetFrameFromSurface(surface.get());
227 ASSERT_EQ(1u, frame.render_pass_list.size()); 234 ASSERT_EQ(1u, frame.render_pass_list.size());
228 ASSERT_EQ(1u, frame.render_pass_list.back()->quad_list.size()); 235 ASSERT_EQ(1u, frame.render_pass_list.back()->quad_list.size());
229 cc::DrawQuad* draw_quad = frame.render_pass_list.back()->quad_list.back(); 236 cc::DrawQuad* draw_quad = frame.render_pass_list.back()->quad_list.back();
230 ASSERT_EQ(cc::DrawQuad::TEXTURE_CONTENT, draw_quad->material); 237 ASSERT_EQ(cc::DrawQuad::TEXTURE_CONTENT, draw_quad->material);
231 238
232 const cc::TextureDrawQuad* texture_quad = 239 const cc::TextureDrawQuad* texture_quad =
233 cc::TextureDrawQuad::MaterialCast(draw_quad); 240 cc::TextureDrawQuad::MaterialCast(draw_quad);
234 EXPECT_FALSE(texture_quad->resource_size_in_pixels().IsEmpty()); 241 EXPECT_FALSE(texture_quad->resource_size_in_pixels().IsEmpty());
(...skipping 12 matching lines...) Expand all
247 254
248 TEST_F(SurfaceTest, Commit) { 255 TEST_F(SurfaceTest, Commit) {
249 std::unique_ptr<Surface> surface(new Surface); 256 std::unique_ptr<Surface> surface(new Surface);
250 257
251 // Calling commit without a buffer should succeed. 258 // Calling commit without a buffer should succeed.
252 surface->Commit(); 259 surface->Commit();
253 } 260 }
254 261
255 } // namespace 262 } // namespace
256 } // namespace exo 263 } // namespace exo
OLDNEW
« no previous file with comments | « components/exo/surface.cc ('k') | components/exo/test/run_all_unittests.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698