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

Side by Side Diff: cc/surfaces/surface_hittest_unittest.cc

Issue 1866203004: Convert //cc from scoped_ptr to std::unique_ptr. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: scopedptrcc: rebase Created 4 years, 8 months 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 | « cc/surfaces/surface_factory_unittest.cc ('k') | cc/surfaces/surface_manager.h » ('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 <stddef.h> 5 #include <stddef.h>
6 6
7 #include "cc/output/compositor_frame.h" 7 #include "cc/output/compositor_frame.h"
8 #include "cc/surfaces/surface.h" 8 #include "cc/surfaces/surface.h"
9 #include "cc/surfaces/surface_factory.h" 9 #include "cc/surfaces/surface_factory.h"
10 #include "cc/surfaces/surface_factory_client.h" 10 #include "cc/surfaces/surface_factory_client.h"
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
59 // This test verifies that hit testing on a surface that does not exist does 59 // This test verifies that hit testing on a surface that does not exist does
60 // not crash. 60 // not crash.
61 TEST(SurfaceHittestTest, Hittest_BadCompositorFrameDoesNotCrash) { 61 TEST(SurfaceHittestTest, Hittest_BadCompositorFrameDoesNotCrash) {
62 SurfaceManager manager; 62 SurfaceManager manager;
63 EmptySurfaceFactoryClient client; 63 EmptySurfaceFactoryClient client;
64 SurfaceFactory factory(&manager, &client); 64 SurfaceFactory factory(&manager, &client);
65 65
66 // Creates a root surface. 66 // Creates a root surface.
67 gfx::Rect root_rect(300, 300); 67 gfx::Rect root_rect(300, 300);
68 RenderPass* root_pass = nullptr; 68 RenderPass* root_pass = nullptr;
69 scoped_ptr<CompositorFrame> root_frame = 69 std::unique_ptr<CompositorFrame> root_frame =
70 CreateCompositorFrame(root_rect, &root_pass); 70 CreateCompositorFrame(root_rect, &root_pass);
71 71
72 // Add a reference to a non-existant child surface on the root surface. 72 // Add a reference to a non-existant child surface on the root surface.
73 SurfaceIdAllocator child_allocator(3); 73 SurfaceIdAllocator child_allocator(3);
74 SurfaceId child_surface_id; 74 SurfaceId child_surface_id;
75 child_surface_id.id = 0xdeadbeef; 75 child_surface_id.id = 0xdeadbeef;
76 gfx::Rect child_rect(200, 200); 76 gfx::Rect child_rect(200, 200);
77 CreateSurfaceDrawQuad(root_pass, 77 CreateSurfaceDrawQuad(root_pass,
78 gfx::Transform(), 78 gfx::Transform(),
79 root_rect, 79 root_rect,
(...skipping 20 matching lines...) Expand all
100 } 100 }
101 101
102 TEST(SurfaceHittestTest, Hittest_SingleSurface) { 102 TEST(SurfaceHittestTest, Hittest_SingleSurface) {
103 SurfaceManager manager; 103 SurfaceManager manager;
104 EmptySurfaceFactoryClient client; 104 EmptySurfaceFactoryClient client;
105 SurfaceFactory factory(&manager, &client); 105 SurfaceFactory factory(&manager, &client);
106 106
107 // Creates a root surface. 107 // Creates a root surface.
108 gfx::Rect root_rect(300, 300); 108 gfx::Rect root_rect(300, 300);
109 RenderPass* root_pass = nullptr; 109 RenderPass* root_pass = nullptr;
110 scoped_ptr<CompositorFrame> root_frame = 110 std::unique_ptr<CompositorFrame> root_frame =
111 CreateCompositorFrame(root_rect, &root_pass); 111 CreateCompositorFrame(root_rect, &root_pass);
112 112
113 // Submit the root frame. 113 // Submit the root frame.
114 SurfaceIdAllocator root_allocator(2); 114 SurfaceIdAllocator root_allocator(2);
115 SurfaceId root_surface_id = root_allocator.GenerateId(); 115 SurfaceId root_surface_id = root_allocator.GenerateId();
116 factory.Create(root_surface_id); 116 factory.Create(root_surface_id);
117 factory.SubmitCompositorFrame(root_surface_id, std::move(root_frame), 117 factory.SubmitCompositorFrame(root_surface_id, std::move(root_frame),
118 SurfaceFactory::DrawCallback()); 118 SurfaceFactory::DrawCallback());
119 TestCase tests[] = { 119 TestCase tests[] = {
120 { 120 {
(...skipping 10 matching lines...) Expand all
131 } 131 }
132 132
133 TEST(SurfaceHittestTest, Hittest_ChildSurface) { 133 TEST(SurfaceHittestTest, Hittest_ChildSurface) {
134 SurfaceManager manager; 134 SurfaceManager manager;
135 EmptySurfaceFactoryClient client; 135 EmptySurfaceFactoryClient client;
136 SurfaceFactory factory(&manager, &client); 136 SurfaceFactory factory(&manager, &client);
137 137
138 // Creates a root surface. 138 // Creates a root surface.
139 gfx::Rect root_rect(300, 300); 139 gfx::Rect root_rect(300, 300);
140 RenderPass* root_pass = nullptr; 140 RenderPass* root_pass = nullptr;
141 scoped_ptr<CompositorFrame> root_frame = 141 std::unique_ptr<CompositorFrame> root_frame =
142 CreateCompositorFrame(root_rect, &root_pass); 142 CreateCompositorFrame(root_rect, &root_pass);
143 143
144 // Add a reference to the child surface on the root surface. 144 // Add a reference to the child surface on the root surface.
145 SurfaceIdAllocator child_allocator(3); 145 SurfaceIdAllocator child_allocator(3);
146 SurfaceId child_surface_id = child_allocator.GenerateId(); 146 SurfaceId child_surface_id = child_allocator.GenerateId();
147 gfx::Rect child_rect(200, 200); 147 gfx::Rect child_rect(200, 200);
148 CreateSurfaceDrawQuad(root_pass, 148 CreateSurfaceDrawQuad(root_pass,
149 gfx::Transform(1.0f, 0.0f, 0.0f, 50.0f, 149 gfx::Transform(1.0f, 0.0f, 0.0f, 50.0f,
150 0.0f, 1.0f, 0.0f, 50.0f, 150 0.0f, 1.0f, 0.0f, 50.0f,
151 0.0f, 0.0f, 1.0f, 0.0f, 151 0.0f, 0.0f, 1.0f, 0.0f,
152 0.0f, 0.0f, 0.0f, 1.0f), 152 0.0f, 0.0f, 0.0f, 1.0f),
153 root_rect, 153 root_rect,
154 child_rect, 154 child_rect,
155 child_surface_id); 155 child_surface_id);
156 156
157 // Submit the root frame. 157 // Submit the root frame.
158 SurfaceIdAllocator root_allocator(2); 158 SurfaceIdAllocator root_allocator(2);
159 SurfaceId root_surface_id = root_allocator.GenerateId(); 159 SurfaceId root_surface_id = root_allocator.GenerateId();
160 factory.Create(root_surface_id); 160 factory.Create(root_surface_id);
161 factory.SubmitCompositorFrame(root_surface_id, std::move(root_frame), 161 factory.SubmitCompositorFrame(root_surface_id, std::move(root_frame),
162 SurfaceFactory::DrawCallback()); 162 SurfaceFactory::DrawCallback());
163 163
164 // Creates a child surface. 164 // Creates a child surface.
165 RenderPass* child_pass = nullptr; 165 RenderPass* child_pass = nullptr;
166 scoped_ptr<CompositorFrame> child_frame = 166 std::unique_ptr<CompositorFrame> child_frame =
167 CreateCompositorFrame(child_rect, &child_pass); 167 CreateCompositorFrame(child_rect, &child_pass);
168 168
169 // Add a solid quad in the child surface. 169 // Add a solid quad in the child surface.
170 gfx::Rect child_solid_quad_rect(100, 100); 170 gfx::Rect child_solid_quad_rect(100, 100);
171 CreateSolidColorDrawQuad( 171 CreateSolidColorDrawQuad(
172 child_pass, 172 child_pass,
173 gfx::Transform(1.0f, 0.0f, 0.0f, 50.0f, 173 gfx::Transform(1.0f, 0.0f, 0.0f, 50.0f,
174 0.0f, 1.0f, 0.0f, 50.0f, 174 0.0f, 1.0f, 0.0f, 50.0f,
175 0.0f, 0.0f, 1.0f, 0.0f, 175 0.0f, 0.0f, 1.0f, 0.0f,
176 0.0f, 0.0f, 0.0f, 1.0f), 176 0.0f, 0.0f, 0.0f, 1.0f),
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after
264 // This test verifies that hit testing will progress to the next quad if it 264 // This test verifies that hit testing will progress to the next quad if it
265 // encounters an invalid RenderPassDrawQuad for whatever reason. 265 // encounters an invalid RenderPassDrawQuad for whatever reason.
266 TEST(SurfaceHittestTest, Hittest_InvalidRenderPassDrawQuad) { 266 TEST(SurfaceHittestTest, Hittest_InvalidRenderPassDrawQuad) {
267 SurfaceManager manager; 267 SurfaceManager manager;
268 EmptySurfaceFactoryClient client; 268 EmptySurfaceFactoryClient client;
269 SurfaceFactory factory(&manager, &client); 269 SurfaceFactory factory(&manager, &client);
270 270
271 // Creates a root surface. 271 // Creates a root surface.
272 gfx::Rect root_rect(300, 300); 272 gfx::Rect root_rect(300, 300);
273 RenderPass* root_pass = nullptr; 273 RenderPass* root_pass = nullptr;
274 scoped_ptr<CompositorFrame> root_frame = 274 std::unique_ptr<CompositorFrame> root_frame =
275 CreateCompositorFrame(root_rect, &root_pass); 275 CreateCompositorFrame(root_rect, &root_pass);
276 276
277 // Create a RenderPassDrawQuad to a non-existant RenderPass. 277 // Create a RenderPassDrawQuad to a non-existant RenderPass.
278 CreateRenderPassDrawQuad(root_pass, 278 CreateRenderPassDrawQuad(root_pass,
279 gfx::Transform(), 279 gfx::Transform(),
280 root_rect, 280 root_rect,
281 root_rect, 281 root_rect,
282 RenderPassId(1337, 1337)); 282 RenderPassId(1337, 1337));
283 283
284 // Add a reference to the child surface on the root surface. 284 // Add a reference to the child surface on the root surface.
(...skipping 11 matching lines...) Expand all
296 296
297 // Submit the root frame. 297 // Submit the root frame.
298 SurfaceIdAllocator root_allocator(2); 298 SurfaceIdAllocator root_allocator(2);
299 SurfaceId root_surface_id = root_allocator.GenerateId(); 299 SurfaceId root_surface_id = root_allocator.GenerateId();
300 factory.Create(root_surface_id); 300 factory.Create(root_surface_id);
301 factory.SubmitCompositorFrame(root_surface_id, std::move(root_frame), 301 factory.SubmitCompositorFrame(root_surface_id, std::move(root_frame),
302 SurfaceFactory::DrawCallback()); 302 SurfaceFactory::DrawCallback());
303 303
304 // Creates a child surface. 304 // Creates a child surface.
305 RenderPass* child_pass = nullptr; 305 RenderPass* child_pass = nullptr;
306 scoped_ptr<CompositorFrame> child_frame = 306 std::unique_ptr<CompositorFrame> child_frame =
307 CreateCompositorFrame(child_rect, &child_pass); 307 CreateCompositorFrame(child_rect, &child_pass);
308 308
309 // Add a solid quad in the child surface. 309 // Add a solid quad in the child surface.
310 gfx::Rect child_solid_quad_rect(100, 100); 310 gfx::Rect child_solid_quad_rect(100, 100);
311 CreateSolidColorDrawQuad(child_pass, 311 CreateSolidColorDrawQuad(child_pass,
312 gfx::Transform(1.0f, 0.0f, 0.0f, 50.0f, 312 gfx::Transform(1.0f, 0.0f, 0.0f, 50.0f,
313 0.0f, 1.0f, 0.0f, 50.0f, 313 0.0f, 1.0f, 0.0f, 50.0f,
314 0.0f, 0.0f, 1.0f, 0.0f, 314 0.0f, 0.0f, 1.0f, 0.0f,
315 0.0f, 0.0f, 0.0f, 1.0f), 315 0.0f, 0.0f, 0.0f, 1.0f),
316 root_rect, 316 root_rect,
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
385 gfx::Rect(100, 100), 385 gfx::Rect(100, 100),
386 transform_to_root_target, 386 transform_to_root_target,
387 &render_pass_list); 387 &render_pass_list);
388 388
389 // Create the root RenderPass. 389 // Create the root RenderPass.
390 RenderPassId root_render_pass_id(1, 2); 390 RenderPassId root_render_pass_id(1, 2);
391 CreateRenderPass(root_render_pass_id, root_rect, gfx::Transform(), 391 CreateRenderPass(root_render_pass_id, root_rect, gfx::Transform(),
392 &render_pass_list); 392 &render_pass_list);
393 393
394 RenderPass* root_pass = nullptr; 394 RenderPass* root_pass = nullptr;
395 scoped_ptr<CompositorFrame> root_frame = 395 std::unique_ptr<CompositorFrame> root_frame =
396 CreateCompositorFrameWithRenderPassList(&render_pass_list); 396 CreateCompositorFrameWithRenderPassList(&render_pass_list);
397 root_pass = root_frame->delegated_frame_data->render_pass_list.back().get(); 397 root_pass = root_frame->delegated_frame_data->render_pass_list.back().get();
398 398
399 // Create a RenderPassDrawQuad. 399 // Create a RenderPassDrawQuad.
400 gfx::Rect render_pass_quad_rect(100, 100); 400 gfx::Rect render_pass_quad_rect(100, 100);
401 CreateRenderPassDrawQuad(root_pass, 401 CreateRenderPassDrawQuad(root_pass,
402 transform_to_root_target, 402 transform_to_root_target,
403 root_rect, 403 root_rect,
404 render_pass_quad_rect, 404 render_pass_quad_rect,
405 child_render_pass_id); 405 child_render_pass_id);
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
470 } 470 }
471 471
472 TEST(SurfaceHittestTest, Hittest_SingleSurface_WithInsetsDelegate) { 472 TEST(SurfaceHittestTest, Hittest_SingleSurface_WithInsetsDelegate) {
473 SurfaceManager manager; 473 SurfaceManager manager;
474 EmptySurfaceFactoryClient client; 474 EmptySurfaceFactoryClient client;
475 SurfaceFactory factory(&manager, &client); 475 SurfaceFactory factory(&manager, &client);
476 476
477 // Creates a root surface. 477 // Creates a root surface.
478 gfx::Rect root_rect(300, 300); 478 gfx::Rect root_rect(300, 300);
479 RenderPass* root_pass = nullptr; 479 RenderPass* root_pass = nullptr;
480 scoped_ptr<CompositorFrame> root_frame = 480 std::unique_ptr<CompositorFrame> root_frame =
481 CreateCompositorFrame(root_rect, &root_pass); 481 CreateCompositorFrame(root_rect, &root_pass);
482 482
483 // Add a reference to the child surface on the root surface. 483 // Add a reference to the child surface on the root surface.
484 SurfaceIdAllocator child_allocator(3); 484 SurfaceIdAllocator child_allocator(3);
485 SurfaceId child_surface_id = child_allocator.GenerateId(); 485 SurfaceId child_surface_id = child_allocator.GenerateId();
486 gfx::Rect child_rect(200, 200); 486 gfx::Rect child_rect(200, 200);
487 CreateSurfaceDrawQuad( 487 CreateSurfaceDrawQuad(
488 root_pass, 488 root_pass,
489 gfx::Transform(1.0f, 0.0f, 0.0f, 50.0f, 489 gfx::Transform(1.0f, 0.0f, 0.0f, 50.0f,
490 0.0f, 1.0f, 0.0f, 50.0f, 490 0.0f, 1.0f, 0.0f, 50.0f,
491 0.0f, 0.0f, 1.0f, 0.0f, 491 0.0f, 0.0f, 1.0f, 0.0f,
492 0.0f, 0.0f, 0.0f, 1.0f), 492 0.0f, 0.0f, 0.0f, 1.0f),
493 root_rect, child_rect, child_surface_id); 493 root_rect, child_rect, child_surface_id);
494 494
495 // Submit the root frame. 495 // Submit the root frame.
496 SurfaceIdAllocator root_allocator(2); 496 SurfaceIdAllocator root_allocator(2);
497 SurfaceId root_surface_id = root_allocator.GenerateId(); 497 SurfaceId root_surface_id = root_allocator.GenerateId();
498 factory.Create(root_surface_id); 498 factory.Create(root_surface_id);
499 factory.SubmitCompositorFrame(root_surface_id, std::move(root_frame), 499 factory.SubmitCompositorFrame(root_surface_id, std::move(root_frame),
500 SurfaceFactory::DrawCallback()); 500 SurfaceFactory::DrawCallback());
501 501
502 // Creates a child surface. 502 // Creates a child surface.
503 RenderPass* child_pass = nullptr; 503 RenderPass* child_pass = nullptr;
504 scoped_ptr<CompositorFrame> child_frame = 504 std::unique_ptr<CompositorFrame> child_frame =
505 CreateCompositorFrame(child_rect, &child_pass); 505 CreateCompositorFrame(child_rect, &child_pass);
506 506
507 // Add a solid quad in the child surface. 507 // Add a solid quad in the child surface.
508 gfx::Rect child_solid_quad_rect(190, 190); 508 gfx::Rect child_solid_quad_rect(190, 190);
509 CreateSolidColorDrawQuad( 509 CreateSolidColorDrawQuad(
510 child_pass, 510 child_pass,
511 gfx::Transform(1.0f, 0.0f, 0.0f, 5.0f, 0.0f, 1.0f, 0.0f, 5.0f, 0.0f, 0.0f, 511 gfx::Transform(1.0f, 0.0f, 0.0f, 5.0f, 0.0f, 1.0f, 0.0f, 5.0f, 0.0f, 0.0f,
512 1.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f), 512 1.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f),
513 root_rect, child_solid_quad_rect); 513 root_rect, child_solid_quad_rect);
514 514
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after
591 arraysize(test_expectations_with_accept_insets)); 591 arraysize(test_expectations_with_accept_insets));
592 592
593 // Verify that insets have affected hit targeting. 593 // Verify that insets have affected hit targeting.
594 EXPECT_EQ(0, accept_delegate.reject_target_overrides()); 594 EXPECT_EQ(0, accept_delegate.reject_target_overrides());
595 EXPECT_EQ(2, accept_delegate.accept_target_overrides()); 595 EXPECT_EQ(2, accept_delegate.accept_target_overrides());
596 596
597 factory.Destroy(root_surface_id); 597 factory.Destroy(root_surface_id);
598 } 598 }
599 599
600 } // namespace cc 600 } // namespace cc
OLDNEW
« no previous file with comments | « cc/surfaces/surface_factory_unittest.cc ('k') | cc/surfaces/surface_manager.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698