OLD | NEW |
---|---|
(Empty) | |
1 // Copyright 2017 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 "hit_test_aggregator.h" | |
danakj
2017/07/13 15:39:39
full path from src/
the include for the file bein
gklassen
2017/07/13 19:59:14
Done.
| |
6 #include "components/viz/common/frame_sink_id.h" | |
7 #include "components/viz/common/local_surface_id.h" | |
8 #include "components/viz/common/surface_id.h" | |
9 #include "testing/gtest/include/gtest/gtest.h" | |
10 | |
11 namespace viz { | |
danakj
2017/07/13 15:39:39
just viz namespace here
gklassen
2017/07/13 19:59:14
Done.
| |
12 namespace hit_test { | |
13 namespace test { | |
14 | |
15 namespace { | |
16 | |
17 constexpr FrameSinkId kDisplayFrameSink(2, 0); | |
18 | |
19 SurfaceId MakeSurfaceId(const FrameSinkId& frame_sink_id, uint32_t local_id) { | |
20 return SurfaceId( | |
21 frame_sink_id, | |
22 LocalSurfaceId(local_id, base::UnguessableToken::Deserialize(0, 1u))); | |
23 } | |
24 | |
25 } // namespace | |
26 | |
27 using namespace hit_test::mojom; | |
danakj
2017/07/13 15:39:39
do not using namespace: https://google.github.io/s
gklassen
2017/07/13 19:59:15
Done.
| |
28 | |
29 class HitTestAggregatorTest : public testing::Test { | |
30 public: | |
31 HitTestAggregatorTest() {} | |
32 ~HitTestAggregatorTest() override {} | |
33 | |
34 // testing::Test: | |
35 void SetUp() override {} | |
36 void TearDown() override { Reset(); } | |
37 | |
38 HitTestAggregator aggregator_; | |
39 | |
40 int count() { | |
41 AggregatedHitTestRegion* start = | |
42 (AggregatedHitTestRegion*)aggregator_.read_buffer_.get(); | |
43 AggregatedHitTestRegion* end = start; | |
44 while (end->child_count != kEndOfList) | |
45 end++; | |
46 | |
47 int count = end - start; | |
48 return count; | |
49 } | |
50 | |
51 int GetPendingCount() { return aggregator_.pending_.size(); } | |
52 int GetActiveCount() { return aggregator_.active_.size(); } | |
53 | |
54 int GetActiveRegionCount() { return aggregator_.active_region_count_; } | |
55 | |
56 void CallOnSurfaceWillDraw(SurfaceId surface_id) { | |
57 aggregator_.OnSurfaceWillDraw(surface_id); | |
58 } | |
59 | |
60 void CallOnSurfaceDiscarded(SurfaceId surface_id) { | |
61 aggregator_.OnSurfaceDiscarded(surface_id); | |
62 } | |
63 | |
64 void Reset() { | |
65 AggregatedHitTestRegion* regions = | |
66 (AggregatedHitTestRegion*)aggregator_.write_buffer_.get(); | |
danakj
2017/07/13 15:39:39
c++ casts
gklassen
2017/07/13 19:59:14
Done.
| |
67 regions[0].child_count = kEndOfList; | |
68 | |
69 regions = (AggregatedHitTestRegion*)aggregator_.read_buffer_.get(); | |
70 regions[0].child_count = kEndOfList; | |
71 | |
72 aggregator_.pending_.clear(); | |
73 aggregator_.active_.clear(); | |
74 } | |
75 | |
76 int GetHitTestRegionListSize() { return aggregator_.read_size_; } | |
77 | |
78 AggregatedHitTestRegion* GetRegions() { | |
79 return (AggregatedHitTestRegion*)aggregator_.read_buffer_.get(); | |
80 } | |
81 | |
82 // Creates a hit test data element with 8 children recursively to | |
83 // the specified depth. SurfaceIds are generated in sequential order and | |
84 // the method returns the next unused id. | |
85 int CreateAndSubmitHitTestRegionListWith8Children(int id, int depth) { | |
86 SurfaceId surface_id = MakeSurfaceId(kDisplayFrameSink, id); | |
87 id++; | |
88 | |
89 auto hit_test_region_list = HitTestRegionList::New(); | |
90 hit_test_region_list->surface_id = surface_id; | |
91 hit_test_region_list->flags = kHitTestMine; | |
92 hit_test_region_list->bounds.SetRect(0, 0, 1024, 768); | |
93 | |
94 for (int i = 0; i < 8; i++) { | |
95 auto hit_test_region = HitTestRegion::New(); | |
96 hit_test_region->rect.SetRect(100, 100, 100, 100); | |
97 | |
98 if (depth > 0) { | |
99 hit_test_region->flags = kHitTestChildSurface; | |
100 hit_test_region->surface_id = MakeSurfaceId(kDisplayFrameSink, id); | |
101 id = CreateAndSubmitHitTestRegionListWith8Children(id, depth - 1); | |
102 } else { | |
103 hit_test_region->flags = kHitTestMine; | |
104 } | |
105 hit_test_region_list->regions.push_back(std::move(hit_test_region)); | |
106 } | |
107 | |
108 aggregator_.SubmitHitTestRegionList(std::move(hit_test_region_list)); | |
109 return id; | |
110 } | |
111 }; | |
112 | |
113 // TODO(gklassen): Add tests for 3D use cases as suggested by and with | |
114 // input from rjkroege. | |
115 | |
116 // One surface. | |
117 // | |
118 // +----------+ | |
119 // | | | |
120 // | | | |
121 // | | | |
122 // +----------+ | |
123 // | |
124 TEST_F(HitTestAggregatorTest, OneSurface) { | |
125 EXPECT_EQ(count(), 0); | |
126 | |
127 SurfaceId display_surface_id = MakeSurfaceId(kDisplayFrameSink, 1); | |
128 | |
129 auto hit_test_region_list = HitTestRegionList::New(); | |
130 hit_test_region_list->surface_id = display_surface_id; | |
131 hit_test_region_list->flags = kHitTestMine; | |
132 hit_test_region_list->bounds.SetRect(0, 0, 1024, 768); | |
133 | |
134 aggregator_.SubmitHitTestRegionList(std::move(hit_test_region_list)); | |
135 EXPECT_EQ(count(), 0); | |
136 | |
137 EXPECT_EQ(GetPendingCount(), 1); | |
138 EXPECT_EQ(GetActiveCount(), 0); | |
139 | |
140 CallOnSurfaceWillDraw(display_surface_id); | |
141 | |
142 EXPECT_EQ(GetPendingCount(), 0); | |
143 EXPECT_EQ(GetActiveCount(), 1); | |
144 | |
145 aggregator_.Aggregate(display_surface_id); | |
146 aggregator_.Swap(); | |
147 | |
148 // Expect 1 entry routing all events to the one surface (display root). | |
149 EXPECT_EQ(count(), 1); | |
150 | |
151 AggregatedHitTestRegion* regions = GetRegions(); | |
152 | |
153 AggregatedHitTestRegion* region = nullptr; | |
154 | |
155 region = ®ions[0]; | |
156 EXPECT_EQ(region->flags, kHitTestMine); | |
157 EXPECT_EQ(region->frame_sink_id, display_surface_id.frame_sink_id()); | |
158 EXPECT_EQ(region->rect, gfx::Rect(0, 0, 1024, 768)); | |
159 EXPECT_EQ(region->child_count, 0); | |
160 } | |
161 | |
162 // One opaque embedder with two regions. | |
163 // | |
164 // +e-------------+ | |
165 // | +r1-+ +r2--+ | | |
166 // | | | | | | | |
167 // | | | | | | | |
168 // | +---+ +----+ | | |
169 // +--------------+ | |
170 // | |
171 TEST_F(HitTestAggregatorTest, OneEmbedderTwoRegions) { | |
172 EXPECT_EQ(count(), 0); | |
173 | |
174 SurfaceId e_surface_id = MakeSurfaceId(kDisplayFrameSink, 1); | |
175 | |
176 auto e_hit_test_data = HitTestRegionList::New(); | |
177 e_hit_test_data->surface_id = e_surface_id; | |
178 e_hit_test_data->flags = kHitTestMine; | |
179 e_hit_test_data->bounds.SetRect(0, 0, 1024, 768); | |
180 | |
181 auto e_hit_test_region_r1 = HitTestRegion::New(); | |
182 e_hit_test_region_r1->flags = kHitTestMine; | |
183 e_hit_test_region_r1->rect.SetRect(100, 100, 200, 400); | |
184 | |
185 auto e_hit_test_region_r2 = HitTestRegion::New(); | |
186 e_hit_test_region_r2->flags = kHitTestMine; | |
187 e_hit_test_region_r2->rect.SetRect(400, 100, 300, 400); | |
188 | |
189 e_hit_test_data->regions.push_back(std::move(e_hit_test_region_r1)); | |
190 e_hit_test_data->regions.push_back(std::move(e_hit_test_region_r2)); | |
191 | |
192 // Submit HitTestRegionList. | |
193 | |
194 EXPECT_EQ(GetPendingCount(), 0); | |
danakj
2017/07/13 15:39:39
It looks like all the tests here are inverted, you
gklassen
2017/07/13 19:59:14
It did seem to get the right output - currently on
danakj
2017/07/13 20:10:30
Maybe gtest has changed... O_o It used to say
bla
varkha
2017/07/13 20:29:28
Is it this (was news to me as well):
https://chrom
| |
195 | |
196 aggregator_.SubmitHitTestRegionList(std::move(e_hit_test_data)); | |
197 EXPECT_EQ(GetPendingCount(), 1); | |
198 | |
199 // Add Surfaces to DisplayFrame in unexpected order. | |
200 | |
201 EXPECT_EQ(count(), 0); | |
202 EXPECT_EQ(GetActiveCount(), 0); | |
203 | |
204 CallOnSurfaceWillDraw(e_surface_id); | |
205 EXPECT_EQ(GetActiveCount(), 1); | |
206 | |
207 // Aggregate and swap. | |
208 | |
209 aggregator_.Aggregate(e_surface_id); | |
210 EXPECT_EQ(count(), 0); | |
211 | |
212 aggregator_.Swap(); | |
213 EXPECT_EQ(count(), 3); | |
214 | |
215 AggregatedHitTestRegion* regions = GetRegions(); | |
216 | |
217 AggregatedHitTestRegion* region = nullptr; | |
218 | |
219 region = ®ions[0]; | |
220 EXPECT_EQ(region->flags, kHitTestMine); | |
221 EXPECT_EQ(region->frame_sink_id, e_surface_id.frame_sink_id()); | |
222 EXPECT_EQ(region->rect, gfx::Rect(0, 0, 1024, 768)); | |
223 EXPECT_EQ(region->child_count, 2); | |
224 | |
225 region = ®ions[1]; | |
226 EXPECT_EQ(region->flags, kHitTestMine); | |
227 EXPECT_EQ(region->rect, gfx::Rect(100, 100, 200, 400)); | |
228 EXPECT_EQ(region->child_count, 0); | |
229 | |
230 region = ®ions[2]; | |
231 EXPECT_EQ(region->flags, kHitTestMine); | |
232 EXPECT_EQ(region->rect, gfx::Rect(400, 100, 300, 400)); | |
233 EXPECT_EQ(region->child_count, 0); | |
234 } | |
235 | |
236 // One embedder with two children. | |
237 // | |
238 // +e-------------+ | |
239 // | +c1-+ +c2--+ | | |
240 // | | | | | | | |
241 // | | | | | | | |
242 // | +---+ +----+ | | |
243 // +--------------+ | |
244 // | |
245 | |
246 TEST_F(HitTestAggregatorTest, OneEmbedderTwoChildren) { | |
247 EXPECT_EQ(count(), 0); | |
248 | |
249 SurfaceId e_surface_id = MakeSurfaceId(kDisplayFrameSink, 1); | |
250 SurfaceId c1_surface_id = MakeSurfaceId(kDisplayFrameSink, 2); | |
251 SurfaceId c2_surface_id = MakeSurfaceId(kDisplayFrameSink, 3); | |
252 | |
253 auto e_hit_test_data = HitTestRegionList::New(); | |
254 e_hit_test_data->surface_id = e_surface_id; | |
255 e_hit_test_data->flags = kHitTestMine; | |
256 e_hit_test_data->bounds.SetRect(0, 0, 1024, 768); | |
257 | |
258 auto e_hit_test_region_c1 = HitTestRegion::New(); | |
259 e_hit_test_region_c1->flags = kHitTestChildSurface; | |
260 e_hit_test_region_c1->surface_id = c1_surface_id; | |
261 e_hit_test_region_c1->rect.SetRect(100, 100, 200, 300); | |
262 | |
263 auto e_hit_test_region_c2 = HitTestRegion::New(); | |
264 e_hit_test_region_c2->flags = kHitTestChildSurface; | |
265 e_hit_test_region_c2->surface_id = c2_surface_id; | |
266 e_hit_test_region_c2->rect.SetRect(400, 100, 400, 300); | |
267 | |
268 e_hit_test_data->regions.push_back(std::move(e_hit_test_region_c1)); | |
269 e_hit_test_data->regions.push_back(std::move(e_hit_test_region_c2)); | |
270 | |
271 auto c1_hit_test_data = HitTestRegionList::New(); | |
272 c1_hit_test_data->surface_id = c1_surface_id; | |
273 | |
274 auto c2_hit_test_data = HitTestRegionList::New(); | |
275 c2_hit_test_data->surface_id = c2_surface_id; | |
276 | |
277 // Submit in unexpected order. | |
278 | |
279 EXPECT_EQ(GetPendingCount(), 0); | |
280 | |
281 aggregator_.SubmitHitTestRegionList(std::move(c1_hit_test_data)); | |
282 EXPECT_EQ(GetPendingCount(), 1); | |
283 | |
284 aggregator_.SubmitHitTestRegionList(std::move(e_hit_test_data)); | |
285 EXPECT_EQ(GetPendingCount(), 2); | |
286 | |
287 aggregator_.SubmitHitTestRegionList(std::move(c2_hit_test_data)); | |
288 EXPECT_EQ(GetPendingCount(), 3); | |
289 | |
290 // Surfaces added to DisplayFrame in unexpected order. | |
291 | |
292 EXPECT_EQ(count(), 0); | |
293 | |
294 EXPECT_EQ(GetActiveCount(), 0); | |
295 | |
296 CallOnSurfaceWillDraw(c2_surface_id); | |
297 EXPECT_EQ(GetActiveCount(), 1); | |
298 | |
299 CallOnSurfaceWillDraw(c1_surface_id); | |
300 EXPECT_EQ(GetActiveCount(), 2); | |
301 | |
302 CallOnSurfaceWillDraw(e_surface_id); | |
303 EXPECT_EQ(GetActiveCount(), 3); | |
304 | |
305 // Aggregate and swap. | |
306 | |
307 aggregator_.Aggregate(e_surface_id); | |
308 EXPECT_EQ(count(), 0); | |
309 | |
310 aggregator_.Swap(); | |
311 | |
312 EXPECT_EQ(count(), 3); | |
313 | |
314 AggregatedHitTestRegion* regions = GetRegions(); | |
315 | |
316 AggregatedHitTestRegion* region = nullptr; | |
317 | |
318 region = ®ions[0]; | |
319 EXPECT_EQ(region->flags, kHitTestMine); | |
320 EXPECT_EQ(region->frame_sink_id, e_surface_id.frame_sink_id()); | |
321 EXPECT_EQ(region->rect, gfx::Rect(0, 0, 1024, 768)); | |
322 EXPECT_EQ(region->child_count, 2); | |
323 | |
324 region = ®ions[1]; | |
325 EXPECT_EQ(region->flags, kHitTestChildSurface); | |
326 EXPECT_EQ(region->frame_sink_id, c1_surface_id.frame_sink_id()); | |
327 EXPECT_EQ(region->rect, gfx::Rect(100, 100, 200, 300)); | |
328 EXPECT_EQ(region->child_count, 0); | |
329 | |
330 region = ®ions[2]; | |
331 EXPECT_EQ(region->flags, kHitTestChildSurface); | |
332 EXPECT_EQ(region->frame_sink_id, c2_surface_id.frame_sink_id()); | |
333 EXPECT_EQ(region->rect, gfx::Rect(400, 100, 400, 300)); | |
334 EXPECT_EQ(region->child_count, 0); | |
335 } | |
336 | |
337 // Occluded child frame (OOPIF). | |
338 // | |
339 // +e-----------+ | |
340 // | +c--+ | | |
341 // | | +div-+ | | |
342 // | | | | | | |
343 // | | +----+ | | |
344 // | +---+ | | |
345 // +------------+ | |
346 // | |
347 | |
348 TEST_F(HitTestAggregatorTest, OccludedChildFrame) { | |
349 EXPECT_EQ(count(), 0); | |
350 | |
351 SurfaceId e_surface_id = MakeSurfaceId(kDisplayFrameSink, 1); | |
352 SurfaceId c_surface_id = MakeSurfaceId(kDisplayFrameSink, 2); | |
353 | |
354 auto e_hit_test_data = HitTestRegionList::New(); | |
355 e_hit_test_data->surface_id = e_surface_id; | |
356 e_hit_test_data->flags = kHitTestMine; | |
357 e_hit_test_data->bounds.SetRect(0, 0, 1024, 768); | |
358 | |
359 auto e_hit_test_region_div = HitTestRegion::New(); | |
360 e_hit_test_region_div->flags = kHitTestMine; | |
361 e_hit_test_region_div->surface_id = e_surface_id; | |
362 e_hit_test_region_div->rect.SetRect(200, 200, 300, 200); | |
363 | |
364 auto e_hit_test_region_c = HitTestRegion::New(); | |
365 e_hit_test_region_c->flags = kHitTestChildSurface; | |
366 e_hit_test_region_c->surface_id = c_surface_id; | |
367 e_hit_test_region_c->rect.SetRect(100, 100, 200, 500); | |
368 | |
369 e_hit_test_data->regions.push_back(std::move(e_hit_test_region_div)); | |
370 e_hit_test_data->regions.push_back(std::move(e_hit_test_region_c)); | |
371 | |
372 auto c_hit_test_data = HitTestRegionList::New(); | |
373 c_hit_test_data->surface_id = c_surface_id; | |
374 c_hit_test_data->flags = kHitTestMine; | |
375 c_hit_test_data->bounds.SetRect(0, 0, 200, 500); | |
376 | |
377 // Submit in unexpected order. | |
378 | |
379 EXPECT_EQ(GetPendingCount(), 0); | |
380 | |
381 aggregator_.SubmitHitTestRegionList(std::move(c_hit_test_data)); | |
382 EXPECT_EQ(GetPendingCount(), 1); | |
383 | |
384 aggregator_.SubmitHitTestRegionList(std::move(e_hit_test_data)); | |
385 EXPECT_EQ(GetPendingCount(), 2); | |
386 | |
387 // Surfaces added to DisplayFrame in unexpected order. | |
388 | |
389 EXPECT_EQ(count(), 0); | |
390 | |
391 EXPECT_EQ(GetActiveCount(), 0); | |
392 | |
393 CallOnSurfaceWillDraw(e_surface_id); | |
394 EXPECT_EQ(GetActiveCount(), 1); | |
395 | |
396 CallOnSurfaceWillDraw(c_surface_id); | |
397 EXPECT_EQ(GetActiveCount(), 2); | |
398 | |
399 // Aggregate and swap. | |
400 | |
401 aggregator_.Aggregate(e_surface_id); | |
402 EXPECT_EQ(count(), 0); | |
403 | |
404 aggregator_.Swap(); | |
405 | |
406 EXPECT_EQ(count(), 3); | |
407 | |
408 AggregatedHitTestRegion* regions = GetRegions(); | |
409 | |
410 AggregatedHitTestRegion* region = nullptr; | |
411 | |
412 region = ®ions[0]; | |
413 EXPECT_EQ(region->flags, kHitTestMine); | |
414 EXPECT_EQ(region->frame_sink_id, e_surface_id.frame_sink_id()); | |
415 EXPECT_EQ(region->rect, gfx::Rect(0, 0, 1024, 768)); | |
416 EXPECT_EQ(region->child_count, 2); | |
417 | |
418 region = ®ions[1]; | |
419 EXPECT_EQ(region->flags, kHitTestMine); | |
420 EXPECT_EQ(region->frame_sink_id, e_surface_id.frame_sink_id()); | |
421 EXPECT_EQ(region->rect, gfx::Rect(200, 200, 300, 200)); | |
422 EXPECT_EQ(region->child_count, 0); | |
423 | |
424 region = ®ions[2]; | |
425 EXPECT_EQ(region->flags, kHitTestChildSurface | kHitTestMine); | |
426 EXPECT_EQ(region->frame_sink_id, c_surface_id.frame_sink_id()); | |
427 EXPECT_EQ(region->rect, gfx::Rect(100, 100, 200, 500)); | |
428 EXPECT_EQ(region->child_count, 0); | |
429 } | |
430 | |
431 // Foreground child frame (OOPIF). | |
432 // Same as the previous test except the child is foreground. | |
433 // | |
434 // +e-----------+ | |
435 // | +c--+ | | |
436 // | | |div-+ | | |
437 // | | | | | | |
438 // | | |----+ | | |
439 // | +---+ | | |
440 // +------------+ | |
441 // | |
442 | |
443 TEST_F(HitTestAggregatorTest, ForegroundChildFrame) { | |
444 EXPECT_EQ(count(), 0); | |
445 | |
446 SurfaceId e_surface_id = MakeSurfaceId(kDisplayFrameSink, 1); | |
447 SurfaceId c_surface_id = MakeSurfaceId(kDisplayFrameSink, 2); | |
448 | |
449 auto e_hit_test_data = HitTestRegionList::New(); | |
450 e_hit_test_data->surface_id = e_surface_id; | |
451 e_hit_test_data->flags = kHitTestMine; | |
452 e_hit_test_data->bounds.SetRect(0, 0, 1024, 768); | |
453 | |
454 auto e_hit_test_region_div = HitTestRegion::New(); | |
455 e_hit_test_region_div->flags = kHitTestMine; | |
456 e_hit_test_region_div->surface_id = e_surface_id; | |
457 e_hit_test_region_div->rect.SetRect(200, 200, 300, 200); | |
458 | |
459 auto e_hit_test_region_c = HitTestRegion::New(); | |
460 e_hit_test_region_c->flags = kHitTestChildSurface; | |
461 e_hit_test_region_c->surface_id = c_surface_id; | |
462 e_hit_test_region_c->rect.SetRect(100, 100, 200, 500); | |
463 | |
464 e_hit_test_data->regions.push_back(std::move(e_hit_test_region_c)); | |
465 e_hit_test_data->regions.push_back(std::move(e_hit_test_region_div)); | |
466 | |
467 auto c_hit_test_data = HitTestRegionList::New(); | |
468 c_hit_test_data->surface_id = c_surface_id; | |
469 c_hit_test_data->flags = kHitTestMine; | |
470 c_hit_test_data->bounds.SetRect(0, 0, 200, 500); | |
471 | |
472 // Submit in unexpected order. | |
473 | |
474 EXPECT_EQ(GetPendingCount(), 0); | |
475 | |
476 aggregator_.SubmitHitTestRegionList(std::move(c_hit_test_data)); | |
477 EXPECT_EQ(GetPendingCount(), 1); | |
478 | |
479 aggregator_.SubmitHitTestRegionList(std::move(e_hit_test_data)); | |
480 EXPECT_EQ(GetPendingCount(), 2); | |
481 | |
482 // Surfaces added to DisplayFrame in unexpected order. | |
483 | |
484 EXPECT_EQ(count(), 0); | |
485 | |
486 EXPECT_EQ(GetActiveCount(), 0); | |
487 | |
488 CallOnSurfaceWillDraw(e_surface_id); | |
489 EXPECT_EQ(GetActiveCount(), 1); | |
490 | |
491 CallOnSurfaceWillDraw(c_surface_id); | |
492 EXPECT_EQ(GetActiveCount(), 2); | |
493 | |
494 // Aggregate and swap. | |
495 | |
496 aggregator_.Aggregate(e_surface_id); | |
497 EXPECT_EQ(count(), 0); | |
498 | |
499 aggregator_.Swap(); | |
500 | |
501 EXPECT_EQ(count(), 3); | |
502 | |
503 AggregatedHitTestRegion* regions = GetRegions(); | |
504 | |
505 AggregatedHitTestRegion* region = nullptr; | |
506 | |
507 region = ®ions[0]; | |
508 EXPECT_EQ(region->flags, kHitTestMine); | |
509 EXPECT_EQ(region->frame_sink_id, e_surface_id.frame_sink_id()); | |
510 EXPECT_EQ(region->rect, gfx::Rect(0, 0, 1024, 768)); | |
511 EXPECT_EQ(region->child_count, 2); | |
512 | |
513 region = ®ions[1]; | |
514 EXPECT_EQ(region->flags, kHitTestChildSurface | kHitTestMine); | |
515 EXPECT_EQ(region->frame_sink_id, c_surface_id.frame_sink_id()); | |
516 EXPECT_EQ(region->rect, gfx::Rect(100, 100, 200, 500)); | |
517 EXPECT_EQ(region->child_count, 0); | |
518 | |
519 region = ®ions[2]; | |
520 EXPECT_EQ(region->flags, kHitTestMine); | |
521 EXPECT_EQ(region->frame_sink_id, e_surface_id.frame_sink_id()); | |
522 EXPECT_EQ(region->rect, gfx::Rect(200, 200, 300, 200)); | |
523 EXPECT_EQ(region->child_count, 0); | |
524 } | |
525 | |
526 // One embedder with a clipped child with a tab and transparent background. | |
527 // | |
528 // +e-------------+ | |
529 // | +c---------| Point maps to | |
530 // | 1 |+a--+ | ----- ------- | |
531 // | || 2 | 3 | 1 e | |
532 // | |+b--------| 2 a | |
533 // | || | 3 e (transparent area in c) | |
534 // | || 4 | 4 b | |
535 // +--------------+ | |
536 // | |
537 | |
538 TEST_F(HitTestAggregatorTest, ClippedChildWithTabAndTransparentBackground) { | |
539 EXPECT_EQ(count(), 0); | |
540 | |
541 SurfaceId e_surface_id = MakeSurfaceId(kDisplayFrameSink, 1); | |
542 SurfaceId c_surface_id = MakeSurfaceId(kDisplayFrameSink, 2); | |
543 SurfaceId a_surface_id = MakeSurfaceId(kDisplayFrameSink, 3); | |
544 SurfaceId b_surface_id = MakeSurfaceId(kDisplayFrameSink, 4); | |
545 | |
546 auto e_hit_test_data = HitTestRegionList::New(); | |
547 e_hit_test_data->surface_id = e_surface_id; | |
548 e_hit_test_data->flags = kHitTestMine; | |
549 e_hit_test_data->bounds.SetRect(0, 0, 1024, 768); | |
550 | |
551 auto e_hit_test_region_c = HitTestRegion::New(); | |
552 e_hit_test_region_c->flags = kHitTestChildSurface; | |
553 e_hit_test_region_c->surface_id = c_surface_id; | |
554 e_hit_test_region_c->rect.SetRect(200, 100, 1600, 800); | |
555 e_hit_test_region_c->transform.Translate(200, 100); | |
556 | |
557 e_hit_test_data->regions.push_back(std::move(e_hit_test_region_c)); | |
558 | |
559 auto c_hit_test_data = HitTestRegionList::New(); | |
560 c_hit_test_data->surface_id = c_surface_id; | |
561 c_hit_test_data->flags = kHitTestIgnore; | |
562 c_hit_test_data->bounds.SetRect(0, 0, 1600, 800); | |
563 | |
564 auto c_hit_test_region_a = HitTestRegion::New(); | |
565 c_hit_test_region_a->flags = kHitTestChildSurface; | |
566 c_hit_test_region_a->surface_id = a_surface_id; | |
567 c_hit_test_region_a->rect.SetRect(0, 0, 200, 100); | |
568 | |
569 auto c_hit_test_region_b = HitTestRegion::New(); | |
570 c_hit_test_region_b->flags = kHitTestChildSurface; | |
571 c_hit_test_region_b->surface_id = b_surface_id; | |
572 c_hit_test_region_b->rect.SetRect(0, 100, 800, 600); | |
573 | |
574 c_hit_test_data->regions.push_back(std::move(c_hit_test_region_a)); | |
575 c_hit_test_data->regions.push_back(std::move(c_hit_test_region_b)); | |
576 | |
577 auto a_hit_test_data = HitTestRegionList::New(); | |
578 a_hit_test_data->surface_id = a_surface_id; | |
579 a_hit_test_data->flags = kHitTestMine; | |
580 a_hit_test_data->bounds.SetRect(0, 0, 200, 100); | |
581 | |
582 auto b_hit_test_data = HitTestRegionList::New(); | |
583 b_hit_test_data->surface_id = b_surface_id; | |
584 b_hit_test_data->flags = kHitTestMine; | |
585 b_hit_test_data->bounds.SetRect(0, 100, 800, 600); | |
586 | |
587 // Submit in unexpected order. | |
588 | |
589 EXPECT_EQ(GetPendingCount(), 0); | |
590 | |
591 aggregator_.SubmitHitTestRegionList(std::move(c_hit_test_data)); | |
592 EXPECT_EQ(GetPendingCount(), 1); | |
593 | |
594 aggregator_.SubmitHitTestRegionList(std::move(a_hit_test_data)); | |
595 EXPECT_EQ(GetPendingCount(), 2); | |
596 | |
597 aggregator_.SubmitHitTestRegionList(std::move(b_hit_test_data)); | |
598 EXPECT_EQ(GetPendingCount(), 3); | |
599 | |
600 aggregator_.SubmitHitTestRegionList(std::move(e_hit_test_data)); | |
601 EXPECT_EQ(GetPendingCount(), 4); | |
602 | |
603 // Surfaces added to DisplayFrame in unexpected order. | |
604 | |
605 EXPECT_EQ(count(), 0); | |
606 | |
607 EXPECT_EQ(GetActiveCount(), 0); | |
608 | |
609 CallOnSurfaceWillDraw(c_surface_id); | |
610 EXPECT_EQ(GetActiveCount(), 1); | |
611 | |
612 CallOnSurfaceWillDraw(e_surface_id); | |
613 EXPECT_EQ(GetActiveCount(), 2); | |
614 | |
615 CallOnSurfaceWillDraw(b_surface_id); | |
616 EXPECT_EQ(GetActiveCount(), 3); | |
617 | |
618 CallOnSurfaceWillDraw(a_surface_id); | |
619 EXPECT_EQ(GetActiveCount(), 4); | |
620 | |
621 // Aggregate and swap. | |
622 | |
623 aggregator_.Aggregate(e_surface_id); | |
624 EXPECT_EQ(count(), 0); | |
625 | |
626 aggregator_.Swap(); | |
627 | |
628 EXPECT_EQ(count(), 4); | |
629 | |
630 AggregatedHitTestRegion* regions = GetRegions(); | |
631 | |
632 AggregatedHitTestRegion* region = nullptr; | |
633 | |
634 region = ®ions[0]; | |
635 EXPECT_EQ(region->flags, kHitTestMine); | |
636 EXPECT_EQ(region->frame_sink_id, e_surface_id.frame_sink_id()); | |
637 EXPECT_EQ(region->rect, gfx::Rect(0, 0, 1024, 768)); | |
638 EXPECT_EQ(region->child_count, 3); | |
639 | |
640 region = ®ions[1]; | |
641 EXPECT_EQ(region->flags, kHitTestChildSurface | kHitTestIgnore); | |
642 EXPECT_EQ(region->frame_sink_id, c_surface_id.frame_sink_id()); | |
643 EXPECT_EQ(region->rect, gfx::Rect(200, 100, 1600, 800)); | |
644 EXPECT_EQ(region->child_count, 2); | |
645 | |
646 gfx::Point point(300, 300); | |
647 region->transform.TransformPointReverse(&point); | |
648 EXPECT_TRUE(point == gfx::Point(100, 200)); | |
649 | |
650 region = ®ions[2]; | |
651 EXPECT_EQ(region->flags, kHitTestChildSurface | kHitTestMine); | |
652 EXPECT_EQ(region->frame_sink_id, a_surface_id.frame_sink_id()); | |
653 EXPECT_EQ(region->rect, gfx::Rect(0, 0, 200, 100)); | |
654 EXPECT_EQ(region->child_count, 0); | |
655 | |
656 region = ®ions[3]; | |
657 EXPECT_EQ(region->flags, kHitTestChildSurface | kHitTestMine); | |
658 EXPECT_EQ(region->frame_sink_id, b_surface_id.frame_sink_id()); | |
659 EXPECT_EQ(region->rect, gfx::Rect(0, 100, 800, 600)); | |
660 EXPECT_EQ(region->child_count, 0); | |
661 } | |
662 | |
663 // Three children deep. | |
664 // | |
665 // +e------------+ | |
666 // | +c1-------+ | | |
667 // | | +c2---+ | | | |
668 // | | | +c3-| | | | |
669 // | | | | | | | | |
670 // | | | +---| | | | |
671 // | | +-----+ | | | |
672 // | +---------+ | | |
673 // +-------------+ | |
674 // | |
675 | |
676 TEST_F(HitTestAggregatorTest, ThreeChildrenDeep) { | |
677 EXPECT_EQ(count(), 0); | |
678 | |
679 SurfaceId e_surface_id = MakeSurfaceId(kDisplayFrameSink, 1); | |
680 SurfaceId c1_surface_id = MakeSurfaceId(kDisplayFrameSink, 2); | |
681 SurfaceId c2_surface_id = MakeSurfaceId(kDisplayFrameSink, 3); | |
682 SurfaceId c3_surface_id = MakeSurfaceId(kDisplayFrameSink, 4); | |
683 | |
684 auto e_hit_test_data = HitTestRegionList::New(); | |
685 e_hit_test_data->surface_id = e_surface_id; | |
686 e_hit_test_data->flags = kHitTestMine; | |
687 e_hit_test_data->bounds.SetRect(0, 0, 1024, 768); | |
688 | |
689 auto e_hit_test_region_c1 = HitTestRegion::New(); | |
690 e_hit_test_region_c1->flags = kHitTestChildSurface; | |
691 e_hit_test_region_c1->surface_id = c1_surface_id; | |
692 e_hit_test_region_c1->rect.SetRect(100, 100, 700, 700); | |
693 | |
694 e_hit_test_data->regions.push_back(std::move(e_hit_test_region_c1)); | |
695 | |
696 auto c1_hit_test_data = HitTestRegionList::New(); | |
697 c1_hit_test_data->surface_id = c1_surface_id; | |
698 c1_hit_test_data->flags = kHitTestMine; | |
699 c1_hit_test_data->bounds.SetRect(0, 0, 600, 600); | |
700 | |
701 auto c1_hit_test_region_c2 = HitTestRegion::New(); | |
702 c1_hit_test_region_c2->flags = kHitTestChildSurface; | |
703 c1_hit_test_region_c2->surface_id = c2_surface_id; | |
704 c1_hit_test_region_c2->rect.SetRect(100, 100, 500, 500); | |
705 | |
706 c1_hit_test_data->regions.push_back(std::move(c1_hit_test_region_c2)); | |
707 | |
708 auto c2_hit_test_data = HitTestRegionList::New(); | |
709 c2_hit_test_data->surface_id = c2_surface_id; | |
710 c2_hit_test_data->flags = kHitTestMine; | |
711 c2_hit_test_data->bounds.SetRect(0, 0, 400, 400); | |
712 | |
713 auto c2_hit_test_region_c3 = HitTestRegion::New(); | |
714 c2_hit_test_region_c3->flags = kHitTestChildSurface; | |
715 c2_hit_test_region_c3->surface_id = c3_surface_id; | |
716 c2_hit_test_region_c3->rect.SetRect(100, 100, 300, 300); | |
717 | |
718 c2_hit_test_data->regions.push_back(std::move(c2_hit_test_region_c3)); | |
719 | |
720 auto c3_hit_test_data = HitTestRegionList::New(); | |
721 c3_hit_test_data->surface_id = c3_surface_id; | |
722 c3_hit_test_data->flags = kHitTestMine; | |
723 c3_hit_test_data->bounds.SetRect(0, 0, 200, 200); | |
724 | |
725 // Submit in unexpected order. | |
726 | |
727 EXPECT_EQ(GetPendingCount(), 0); | |
728 | |
729 aggregator_.SubmitHitTestRegionList(std::move(c1_hit_test_data)); | |
730 EXPECT_EQ(GetPendingCount(), 1); | |
731 | |
732 aggregator_.SubmitHitTestRegionList(std::move(c3_hit_test_data)); | |
733 EXPECT_EQ(GetPendingCount(), 2); | |
734 | |
735 aggregator_.SubmitHitTestRegionList(std::move(e_hit_test_data)); | |
736 EXPECT_EQ(GetPendingCount(), 3); | |
737 | |
738 aggregator_.SubmitHitTestRegionList(std::move(c2_hit_test_data)); | |
739 EXPECT_EQ(GetPendingCount(), 4); | |
740 | |
741 // Surfaces added to DisplayFrame in unexpected order. | |
742 | |
743 EXPECT_EQ(count(), 0); | |
744 | |
745 EXPECT_EQ(GetActiveCount(), 0); | |
746 | |
747 CallOnSurfaceWillDraw(c2_surface_id); | |
748 EXPECT_EQ(GetActiveCount(), 1); | |
749 | |
750 CallOnSurfaceWillDraw(c1_surface_id); | |
751 EXPECT_EQ(GetActiveCount(), 2); | |
752 | |
753 CallOnSurfaceWillDraw(e_surface_id); | |
754 EXPECT_EQ(GetActiveCount(), 3); | |
755 | |
756 CallOnSurfaceWillDraw(c3_surface_id); | |
757 EXPECT_EQ(GetActiveCount(), 4); | |
758 | |
759 // Aggregate and swap. | |
760 | |
761 aggregator_.Aggregate(e_surface_id); | |
762 EXPECT_EQ(count(), 0); | |
763 | |
764 aggregator_.Swap(); | |
765 | |
766 EXPECT_EQ(count(), 4); | |
767 | |
768 AggregatedHitTestRegion* regions = GetRegions(); | |
769 | |
770 AggregatedHitTestRegion* region = nullptr; | |
771 | |
772 region = ®ions[0]; | |
773 EXPECT_EQ(region->flags, kHitTestMine); | |
774 EXPECT_EQ(region->frame_sink_id, e_surface_id.frame_sink_id()); | |
775 EXPECT_EQ(region->rect, gfx::Rect(0, 0, 1024, 768)); | |
776 EXPECT_EQ(region->child_count, 3); | |
777 | |
778 region = ®ions[1]; | |
779 EXPECT_EQ(region->flags, kHitTestChildSurface | kHitTestMine); | |
780 EXPECT_EQ(region->frame_sink_id, c1_surface_id.frame_sink_id()); | |
781 EXPECT_EQ(region->rect, gfx::Rect(100, 100, 700, 700)); | |
782 EXPECT_EQ(region->child_count, 2); | |
783 | |
784 region = ®ions[2]; | |
785 EXPECT_EQ(region->flags, kHitTestChildSurface | kHitTestMine); | |
786 EXPECT_EQ(region->frame_sink_id, c2_surface_id.frame_sink_id()); | |
787 EXPECT_EQ(region->rect, gfx::Rect(100, 100, 500, 500)); | |
788 EXPECT_EQ(region->child_count, 1); | |
789 | |
790 region = ®ions[3]; | |
791 EXPECT_EQ(region->flags, kHitTestChildSurface | kHitTestMine); | |
792 EXPECT_EQ(region->frame_sink_id, c3_surface_id.frame_sink_id()); | |
793 EXPECT_EQ(region->rect, gfx::Rect(100, 100, 300, 300)); | |
794 EXPECT_EQ(region->child_count, 0); | |
795 } | |
796 | |
797 // Missing / late child. | |
798 // | |
799 // +e-----------+ | |
800 // | +c--+ | | |
801 // | | |div-+ | | |
802 // | | | | | | |
803 // | | |----+ | | |
804 // | +---+ | | |
805 // +------------+ | |
806 // | |
807 | |
808 TEST_F(HitTestAggregatorTest, MissingChildFrame) { | |
809 EXPECT_EQ(count(), 0); | |
810 | |
811 SurfaceId e_surface_id = MakeSurfaceId(kDisplayFrameSink, 1); | |
812 SurfaceId c_surface_id = MakeSurfaceId(kDisplayFrameSink, 2); | |
813 | |
814 auto e_hit_test_data = HitTestRegionList::New(); | |
815 e_hit_test_data->surface_id = e_surface_id; | |
816 e_hit_test_data->flags = kHitTestMine; | |
817 e_hit_test_data->bounds.SetRect(0, 0, 1024, 768); | |
818 | |
819 auto e_hit_test_region_div = HitTestRegion::New(); | |
820 e_hit_test_region_div->flags = kHitTestMine; | |
821 e_hit_test_region_div->surface_id = e_surface_id; | |
822 e_hit_test_region_div->rect.SetRect(200, 200, 300, 200); | |
823 | |
824 auto e_hit_test_region_c = HitTestRegion::New(); | |
825 e_hit_test_region_c->flags = kHitTestChildSurface; | |
826 e_hit_test_region_c->surface_id = c_surface_id; | |
827 e_hit_test_region_c->rect.SetRect(100, 100, 200, 500); | |
828 | |
829 e_hit_test_data->regions.push_back(std::move(e_hit_test_region_c)); | |
830 e_hit_test_data->regions.push_back(std::move(e_hit_test_region_div)); | |
831 | |
832 auto c_hit_test_data = HitTestRegionList::New(); | |
833 c_hit_test_data->surface_id = c_surface_id; | |
834 c_hit_test_data->flags = kHitTestMine; | |
835 c_hit_test_data->bounds.SetRect(0, 0, 200, 500); | |
836 | |
837 // Submit in unexpected order, but not the child. | |
838 | |
839 EXPECT_EQ(GetPendingCount(), 0); | |
840 | |
841 aggregator_.SubmitHitTestRegionList(std::move(e_hit_test_data)); | |
842 EXPECT_EQ(GetPendingCount(), 1); | |
843 | |
844 // Surfaces added to DisplayFrame in unexpected order. | |
845 | |
846 EXPECT_EQ(count(), 0); | |
847 | |
848 EXPECT_EQ(GetActiveCount(), 0); | |
849 | |
850 CallOnSurfaceWillDraw(e_surface_id); | |
851 EXPECT_EQ(GetActiveCount(), 1); | |
852 | |
853 // Aggregate and swap. | |
854 | |
855 aggregator_.Aggregate(e_surface_id); | |
856 EXPECT_EQ(count(), 0); | |
857 | |
858 aggregator_.Swap(); | |
859 | |
860 EXPECT_EQ(count(), 2); | |
861 | |
862 AggregatedHitTestRegion* regions = GetRegions(); | |
863 | |
864 AggregatedHitTestRegion* region = nullptr; | |
865 | |
866 region = ®ions[0]; | |
867 EXPECT_EQ(region->flags, kHitTestMine); | |
868 EXPECT_EQ(region->frame_sink_id, e_surface_id.frame_sink_id()); | |
869 EXPECT_EQ(region->rect, gfx::Rect(0, 0, 1024, 768)); | |
870 EXPECT_EQ(region->child_count, 1); | |
871 | |
872 // Child would exist here but it was not included in the Display Frame. | |
873 | |
874 region = ®ions[1]; | |
875 EXPECT_EQ(region->flags, kHitTestMine); | |
876 EXPECT_EQ(region->frame_sink_id, e_surface_id.frame_sink_id()); | |
877 EXPECT_EQ(region->rect, gfx::Rect(200, 200, 300, 200)); | |
878 EXPECT_EQ(region->child_count, 0); | |
879 } | |
880 | |
881 // Exceed limits to ensure that bounds and resize work. | |
882 // | |
883 // A tree of embedders each with 8 children and 4 levels deep = 4096 regions. | |
884 // This will exceed initial allocation and force a resize. | |
885 // | |
886 // +e--------------------------------------------------------+ | |
887 // | +c1----------++c2----------++c3----------++c4----------+| | |
888 // | | +c1--------|| +c1--------|| +c1--------|| +c1--------|| | |
889 // | | | +c1-++c2-|| | +c1-++c2-|| | +c1-++c2-|| | +c1-++c2-|| | |
890 // | | | | || || | | || || | | || || | | || || | |
891 // | | | +---++---|| | +---++---|| | +---++---|| | +---++---|| | |
892 // | +------------++------------++------------++------------+| | |
893 // | +c5----------++c6----------++c7----------++c8----------+| | |
894 // | | +c1--------|| +c1--------|| +c1--------|| +c1--------|| | |
895 // | | | +c1-++c2-|| | +c1-++c2-|| | +c1-++c2-|| | +c1-++c2-|| | |
896 // | | | | || || | | || || | | || || | | || || | |
897 // | | | +---++---|| | +---++---|| | +---++---|| | +---++---|| | |
898 // | +------------++------------++------------++------------+| | |
899 // +---------------------------------------------------------+ | |
900 // | |
901 | |
902 TEST_F(HitTestAggregatorTest, ExceedLimits) { | |
903 EXPECT_EQ(count(), 0); | |
904 | |
905 EXPECT_LT(GetHitTestRegionListSize(), 4096); | |
906 | |
907 SurfaceId display_surface_id = MakeSurfaceId(kDisplayFrameSink, 1); | |
908 | |
909 int next_surface_id = CreateAndSubmitHitTestRegionListWith8Children(1, 3); | |
910 int surface_count = next_surface_id - 1; | |
911 | |
912 EXPECT_EQ(GetPendingCount(), surface_count); | |
913 | |
914 // Mark Surfaces as added to DisplayFrame in unexpected order. | |
915 | |
916 EXPECT_EQ(count(), 0); | |
917 EXPECT_EQ(GetActiveCount(), 0); | |
918 | |
919 for (int i = 1; i <= surface_count; i++) { | |
920 SurfaceId surface_id = MakeSurfaceId(kDisplayFrameSink, i); | |
921 CallOnSurfaceWillDraw(surface_id); | |
922 } | |
923 | |
924 EXPECT_EQ(GetActiveCount(), surface_count); | |
925 | |
926 // Aggregate and swap. | |
927 aggregator_.Aggregate(display_surface_id); | |
928 EXPECT_EQ(count(), 0); | |
929 | |
930 aggregator_.Swap(); | |
931 | |
932 // Expect 4680 regions: | |
933 // 8 children 4 levels deep 8*8*8*8 is 4096 | |
934 // 1 region for each embedder/surface + 584 | |
935 // 1 root + 1 | |
936 // ----- | |
937 // 4681. | |
938 EXPECT_EQ(count(), 4681); | |
939 | |
940 EXPECT_GE(GetHitTestRegionListSize(), 4681); | |
941 } | |
942 | |
943 TEST_F(HitTestAggregatorTest, ActiveRegionCount) { | |
944 EXPECT_EQ(GetActiveRegionCount(), 0); | |
945 | |
946 SurfaceId e_surface_id = MakeSurfaceId(kDisplayFrameSink, 1); | |
947 SurfaceId c_surface_id = MakeSurfaceId(kDisplayFrameSink, 2); | |
948 | |
949 auto e_hit_test_data = HitTestRegionList::New(); | |
950 e_hit_test_data->surface_id = e_surface_id; | |
951 e_hit_test_data->flags = kHitTestMine; | |
952 e_hit_test_data->bounds.SetRect(0, 0, 1024, 768); | |
953 | |
954 auto e_hit_test_region_div = HitTestRegion::New(); | |
955 e_hit_test_region_div->flags = kHitTestMine; | |
956 e_hit_test_region_div->surface_id = e_surface_id; | |
957 e_hit_test_region_div->rect.SetRect(200, 200, 300, 200); | |
958 | |
959 auto e_hit_test_region_c = HitTestRegion::New(); | |
960 e_hit_test_region_c->flags = kHitTestChildSurface; | |
961 e_hit_test_region_c->surface_id = c_surface_id; | |
962 e_hit_test_region_c->rect.SetRect(100, 100, 200, 500); | |
963 | |
964 e_hit_test_data->regions.push_back(std::move(e_hit_test_region_c)); | |
965 e_hit_test_data->regions.push_back(std::move(e_hit_test_region_div)); | |
966 | |
967 auto c_hit_test_data = HitTestRegionList::New(); | |
968 c_hit_test_data->surface_id = c_surface_id; | |
969 c_hit_test_data->flags = kHitTestMine; | |
970 c_hit_test_data->bounds.SetRect(0, 0, 200, 500); | |
971 | |
972 EXPECT_EQ(GetActiveRegionCount(), 0); | |
973 | |
974 // Submit in unexpected order. | |
975 | |
976 EXPECT_EQ(GetPendingCount(), 0); | |
977 | |
978 aggregator_.SubmitHitTestRegionList(std::move(c_hit_test_data)); | |
979 EXPECT_EQ(GetPendingCount(), 1); | |
980 | |
981 aggregator_.SubmitHitTestRegionList(std::move(e_hit_test_data)); | |
982 EXPECT_EQ(GetPendingCount(), 2); | |
983 | |
984 EXPECT_EQ(GetActiveRegionCount(), 0); | |
985 | |
986 // Surfaces added to DisplayFrame in unexpected order. | |
987 | |
988 EXPECT_EQ(count(), 0); | |
989 EXPECT_EQ(GetActiveCount(), 0); | |
990 | |
991 CallOnSurfaceWillDraw(e_surface_id); | |
992 EXPECT_EQ(GetActiveCount(), 1); | |
993 EXPECT_EQ(GetActiveRegionCount(), 2); | |
994 | |
995 CallOnSurfaceWillDraw(c_surface_id); | |
996 EXPECT_EQ(GetActiveCount(), 2); | |
997 EXPECT_EQ(GetActiveRegionCount(), 2); | |
998 | |
999 // Aggregate and swap. | |
1000 | |
1001 aggregator_.Aggregate(e_surface_id); | |
1002 EXPECT_EQ(count(), 0); | |
1003 EXPECT_EQ(GetActiveRegionCount(), 2); | |
1004 | |
1005 aggregator_.Swap(); | |
1006 | |
1007 EXPECT_EQ(count(), 3); | |
1008 EXPECT_EQ(GetActiveRegionCount(), 2); | |
1009 | |
1010 // Discard Surface and ensure active count goes down. | |
1011 | |
1012 CallOnSurfaceDiscarded(c_surface_id); | |
1013 EXPECT_EQ(GetActiveRegionCount(), 2); | |
1014 | |
1015 CallOnSurfaceDiscarded(e_surface_id); | |
1016 EXPECT_EQ(GetActiveRegionCount(), 0); | |
1017 } | |
1018 | |
1019 } // namespace test | |
1020 } // namespace hit_test | |
1021 } // namespace viz | |
OLD | NEW |