Chromium Code Reviews| 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" | |
| 6 #include "cc/surfaces/frame_sink_id.h" | |
| 7 #include "cc/surfaces/local_surface_id.h" | |
| 8 #include "cc/surfaces/surface_id.h" | |
| 9 #include "testing/gtest/include/gtest/gtest.h" | |
| 10 | |
| 11 namespace viz { | |
| 12 namespace hit_test { | |
| 13 namespace test { | |
| 14 | |
| 15 namespace { | |
| 16 | |
| 17 constexpr cc::FrameSinkId kDisplayFrameSink(2, 0); | |
| 18 | |
| 19 cc::SurfaceId MakeSurfaceId(const cc::FrameSinkId& frame_sink_id, | |
| 20 uint32_t local_id) { | |
| 21 return cc::SurfaceId( | |
| 22 frame_sink_id, | |
| 23 cc::LocalSurfaceId(local_id, base::UnguessableToken::Deserialize(0, 1u))); | |
| 24 } | |
| 25 | |
| 26 } // namespace | |
| 27 | |
| 28 using namespace hit_test::mojom; | |
| 29 | |
| 30 class HitTestAggregatorTest : public testing::Test { | |
| 31 public: | |
| 32 HitTestAggregatorTest() {} | |
| 33 ~HitTestAggregatorTest() override {} | |
| 34 | |
| 35 void SetUp() override {} | |
| 36 | |
| 37 void TearDown() override {} | |
| 38 | |
| 39 HitTestAggregator aggregator_; | |
| 40 | |
| 41 int count() { | |
| 42 DisplayHitTestRegion* start = aggregator_.GetCurrentRegions(); | |
| 43 DisplayHitTestRegion* end = start; | |
| 44 while (end->child_count_ != kEndOfList) { | |
| 45 end++; | |
| 46 } | |
| 47 return end - start; | |
| 48 } | |
| 49 | |
| 50 DisplayHitTestRegion* RegionAtIndex(int i) { | |
| 51 return aggregator_.GetCurrentRegions() + i; | |
| 52 } | |
| 53 | |
| 54 int GetPendingCount() { return aggregator_.pending_.size(); } | |
| 55 int GetActiveCount() { return aggregator_.active_.size(); } | |
| 56 | |
| 57 void Reset() { | |
| 58 int size = aggregator_.display_hit_test_data_->size_; | |
| 59 | |
| 60 aggregator_.display_hit_test_data_->regions_[0].child_count_ = kEndOfList; | |
| 61 aggregator_.display_hit_test_data_->regions_[size >> 1].child_count_ = | |
| 62 kEndOfList; | |
| 63 | |
| 64 aggregator_.pending_.clear(); | |
| 65 aggregator_.active_.clear(); | |
| 66 } | |
| 67 }; | |
| 68 | |
| 69 // tests brainstorm & todo | |
|
rjkroege
2017/06/07 21:19:06
you would remove this before landing
gklassen
2017/06/08 20:33:21
ok. Agreed. Done.
| |
| 70 // child transforms | |
| 71 // submit late | |
| 72 // keep surfaces until destroyed | |
| 73 // bowtie | |
| 74 | |
| 75 // one surface | |
|
rjkroege
2017/06/07 21:19:06
Love it! Wonderful!
And... comments need to be se
gklassen
2017/06/08 20:33:21
Agreed. Or should this be added to an .md?
rjkroege
2017/06/09 15:47:07
I like it here.
gklassen
2017/06/12 16:30:41
Acknowledged.
| |
| 76 // | |
| 77 // +----------+ | |
| 78 // | | | |
| 79 // | | | |
| 80 // | | | |
| 81 // +----------+ | |
| 82 // | |
| 83 TEST_F(HitTestAggregatorTest, OneSurface) { | |
| 84 EXPECT_TRUE(count() == 0); | |
| 85 | |
| 86 cc::SurfaceId display_surface_id = MakeSurfaceId(kDisplayFrameSink, 1); | |
| 87 | |
| 88 auto hit_test_data = HitTestData::New(); | |
| 89 hit_test_data->surface_id_ = display_surface_id; | |
| 90 hit_test_data->bounds_.SetRect(0, 0, 1024, 768); | |
|
rjkroege
2017/06/07 21:19:06
So: in this case, the example receives no events y
gklassen
2017/06/08 20:33:21
I will update based on our conversation this morni
| |
| 91 | |
| 92 aggregator_.SubmitHitTestData(std::move(hit_test_data)); | |
| 93 | |
| 94 EXPECT_TRUE(count() == 0); | |
| 95 | |
| 96 EXPECT_TRUE(GetPendingCount() == 1); | |
| 97 EXPECT_TRUE(GetActiveCount() == 0); | |
| 98 | |
| 99 aggregator_.OnSurfaceWillDraw(display_surface_id); | |
| 100 | |
| 101 EXPECT_TRUE(GetPendingCount() == 1); | |
| 102 EXPECT_TRUE(GetActiveCount() == 1); | |
| 103 | |
| 104 aggregator_.Aggregate(display_surface_id); | |
| 105 aggregator_.Swap(); | |
| 106 | |
| 107 // no sub-routing means an empty tree - all events to root | |
|
rjkroege
2017/06/07 21:19:06
Ah. I am not misunderstanding. I hope.
Then you
gklassen
2017/06/08 20:33:21
I will update based on our conversation this morni
| |
| 108 EXPECT_TRUE(count() == 0); | |
| 109 } | |
| 110 | |
| 111 // one embedder two regions | |
| 112 // | |
| 113 // +e------------+ | |
| 114 // | +r1-+ +r2-+ | | |
| 115 // | | | | | | | |
| 116 // | | | | | | | |
| 117 // | +---+ +---+ | | |
| 118 // +-------------+ | |
| 119 // | |
| 120 TEST_F(HitTestAggregatorTest, OneEmbedderTwoRegions) { | |
| 121 Reset(); | |
| 122 EXPECT_TRUE(count() == 0); | |
| 123 | |
| 124 cc::SurfaceId e_surface_id = MakeSurfaceId(kDisplayFrameSink, 1); | |
| 125 | |
| 126 auto e_hit_test_data = HitTestData::New(); | |
| 127 e_hit_test_data->surface_id_ = e_surface_id; | |
| 128 e_hit_test_data->bounds_.SetRect(0, 0, 1024, 768); | |
| 129 | |
| 130 auto r1_hit_test_region = HitTestRegion::New(); | |
| 131 r1_hit_test_region->flags_ = HitTestRegionFlags::HIT_TEST_MINE; | |
| 132 r1_hit_test_region->rect_.SetRect(0, 0, 512, 512); | |
| 133 | |
| 134 auto r2_hit_test_region = HitTestRegion::New(); | |
| 135 r2_hit_test_region->flags_ = HitTestRegionFlags::HIT_TEST_MINE; | |
| 136 r2_hit_test_region->rect_.SetRect(0, 0, 512, 512); | |
|
rjkroege
2017/06/07 21:19:06
the coordinates don't match your picture?
gklassen
2017/06/08 20:33:21
Done.
| |
| 137 | |
| 138 e_hit_test_data->regions_.push_back(std::move(r1_hit_test_region)); | |
| 139 e_hit_test_data->regions_.push_back(std::move(r2_hit_test_region)); | |
| 140 | |
| 141 // submit | |
| 142 | |
| 143 EXPECT_TRUE(GetPendingCount() == 0); | |
| 144 | |
| 145 aggregator_.SubmitHitTestData(std::move(e_hit_test_data)); | |
| 146 EXPECT_TRUE(GetPendingCount() == 1); | |
| 147 | |
| 148 // surfaces added to DisplayFrame ( in unexpected order ) | |
| 149 | |
| 150 EXPECT_TRUE(count() == 0); | |
| 151 EXPECT_TRUE(GetActiveCount() == 0); | |
| 152 | |
| 153 aggregator_.OnSurfaceWillDraw(e_surface_id); | |
| 154 EXPECT_TRUE(GetActiveCount() == 1); | |
| 155 | |
| 156 // aggregate and swap | |
| 157 | |
| 158 aggregator_.Aggregate(e_surface_id); | |
| 159 EXPECT_TRUE(count() == 0); | |
| 160 | |
| 161 aggregator_.Swap(); | |
| 162 EXPECT_TRUE(count() == 3); | |
| 163 | |
| 164 DisplayHitTestRegion* region; | |
| 165 | |
| 166 region = RegionAtIndex(0); | |
| 167 EXPECT_TRUE(region->flags_ == HitTestRegionFlags::HIT_TEST_BOUNDS); | |
| 168 EXPECT_TRUE(region->frame_sink_id_ == e_surface_id.frame_sink_id()); | |
| 169 EXPECT_TRUE(region->rect_ == gfx::Rect(0, 0, 1024, 768)); | |
| 170 EXPECT_TRUE(region->child_count_ == 2); | |
| 171 | |
| 172 region = RegionAtIndex(1); | |
| 173 EXPECT_TRUE(region->flags_ == HitTestRegionFlags::HIT_TEST_MINE); | |
| 174 EXPECT_TRUE(region->rect_ == gfx::Rect(0, 0, 512, 512)); | |
| 175 EXPECT_TRUE(region->child_count_ == 0); | |
| 176 | |
| 177 region = RegionAtIndex(2); | |
| 178 EXPECT_TRUE(region->flags_ == HitTestRegionFlags::HIT_TEST_MINE); | |
| 179 EXPECT_TRUE(region->rect_ == gfx::Rect(0, 0, 512, 512)); | |
| 180 EXPECT_TRUE(region->child_count_ == 0); | |
| 181 } | |
| 182 | |
| 183 // one embedder two children | |
| 184 // | |
| 185 // +e------------+ | |
| 186 // | +c1-+ +c2-+ | | |
| 187 // | | | | | | | |
| 188 // | | | | | | | |
| 189 // | +---+ +---+ | | |
| 190 // +-------------+ | |
| 191 // | |
| 192 | |
| 193 TEST_F(HitTestAggregatorTest, OneEmbedderTwoChildren) { | |
| 194 Reset(); | |
| 195 EXPECT_TRUE(count() == 0); | |
| 196 | |
| 197 cc::SurfaceId e_surface_id = MakeSurfaceId(kDisplayFrameSink, 1); | |
| 198 cc::SurfaceId c1_surface_id = MakeSurfaceId(kDisplayFrameSink, 2); | |
| 199 cc::SurfaceId c2_surface_id = MakeSurfaceId(kDisplayFrameSink, 3); | |
| 200 | |
| 201 auto e_hit_test_data = HitTestData::New(); | |
| 202 e_hit_test_data->surface_id_ = e_surface_id; | |
| 203 e_hit_test_data->bounds_.SetRect(0, 0, 1024, 768); | |
| 204 | |
| 205 auto c1_hit_test_region = HitTestRegion::New(); | |
|
rjkroege
2017/06/07 21:19:06
this needs a better naming convention: it's the hi
gklassen
2017/06/08 20:33:21
Done.
| |
| 206 c1_hit_test_region->flags_ = HitTestRegionFlags::HIT_TEST_CHILD_SURFACE; | |
| 207 c1_hit_test_region->surface_id_ = c1_surface_id; | |
| 208 c1_hit_test_region->rect_.SetRect(0, 0, 512, 512); | |
| 209 | |
| 210 auto c2_hit_test_region = HitTestRegion::New(); | |
| 211 c2_hit_test_region->flags_ = HitTestRegionFlags::HIT_TEST_CHILD_SURFACE; | |
| 212 c2_hit_test_region->surface_id_ = c2_surface_id; | |
| 213 c2_hit_test_region->rect_.SetRect(0, 0, 512, 512); | |
|
rjkroege
2017/06/07 21:19:06
don't match picture. :-)
gklassen
2017/06/08 20:33:21
Done.
| |
| 214 | |
| 215 e_hit_test_data->regions_.push_back(std::move(c1_hit_test_region)); | |
| 216 e_hit_test_data->regions_.push_back(std::move(c2_hit_test_region)); | |
| 217 | |
| 218 auto c1_hit_test_data = HitTestData::New(); | |
|
rjkroege
2017/06/07 21:19:06
the children don't have bounds? i.e.: it's a bare
gklassen
2017/06/08 20:33:22
Will update based on conversation this morning.
| |
| 219 c1_hit_test_data->surface_id_ = c1_surface_id; | |
| 220 | |
| 221 auto c2_hit_test_data = HitTestData::New(); | |
| 222 c2_hit_test_data->surface_id_ = c2_surface_id; | |
| 223 | |
| 224 // submit ( in unexpected order ) | |
| 225 | |
| 226 EXPECT_TRUE(GetPendingCount() == 0); | |
| 227 | |
| 228 aggregator_.SubmitHitTestData(std::move(c1_hit_test_data)); | |
| 229 EXPECT_TRUE(GetPendingCount() == 1); | |
| 230 | |
| 231 aggregator_.SubmitHitTestData(std::move(e_hit_test_data)); | |
| 232 EXPECT_TRUE(GetPendingCount() == 2); | |
| 233 | |
| 234 aggregator_.SubmitHitTestData(std::move(c2_hit_test_data)); | |
| 235 EXPECT_TRUE(GetPendingCount() == 3); | |
| 236 | |
| 237 // surfaces added to DisplayFrame ( in unexpected order ) | |
| 238 | |
| 239 EXPECT_TRUE(count() == 0); | |
| 240 | |
| 241 EXPECT_TRUE(GetActiveCount() == 0); | |
| 242 | |
| 243 aggregator_.OnSurfaceWillDraw(c2_surface_id); | |
| 244 EXPECT_TRUE(GetActiveCount() == 1); | |
| 245 | |
| 246 aggregator_.OnSurfaceWillDraw(c1_surface_id); | |
| 247 EXPECT_TRUE(GetActiveCount() == 2); | |
| 248 | |
| 249 aggregator_.OnSurfaceWillDraw(e_surface_id); | |
| 250 EXPECT_TRUE(GetActiveCount() == 3); | |
| 251 | |
| 252 // aggregate and swap | |
| 253 | |
| 254 aggregator_.Aggregate(e_surface_id); | |
| 255 EXPECT_TRUE(count() == 0); | |
| 256 | |
| 257 aggregator_.Swap(); | |
| 258 | |
| 259 // we expect 5 entries in the tree - one for one for each child | |
|
rjkroege
2017/06/07 21:19:06
Why? The children have no bounds region? or "HIT_T
gklassen
2017/06/08 20:33:21
Will update based on conversation this morning.
| |
| 260 EXPECT_TRUE(count() == 3); | |
| 261 | |
| 262 DisplayHitTestRegion* region; | |
| 263 | |
| 264 region = RegionAtIndex(0); | |
| 265 EXPECT_TRUE(region->flags_ == HitTestRegionFlags::HIT_TEST_BOUNDS); | |
| 266 EXPECT_TRUE(region->frame_sink_id_ == e_surface_id.frame_sink_id()); | |
| 267 EXPECT_TRUE(region->rect_ == gfx::Rect(0, 0, 1024, 768)); | |
| 268 EXPECT_TRUE(region->child_count_ == 2); | |
| 269 | |
| 270 region = RegionAtIndex(1); | |
| 271 EXPECT_TRUE(region->flags_ == HitTestRegionFlags::HIT_TEST_CHILD_SURFACE); | |
| 272 EXPECT_TRUE(region->rect_ == gfx::Rect(0, 0, 512, 512)); | |
| 273 EXPECT_TRUE(region->child_count_ == 0); | |
| 274 | |
| 275 region = RegionAtIndex(2); | |
| 276 EXPECT_TRUE(region->flags_ == HitTestRegionFlags::HIT_TEST_CHILD_SURFACE); | |
| 277 EXPECT_TRUE(region->rect_ == gfx::Rect(0, 0, 512, 512)); | |
| 278 EXPECT_TRUE(region->child_count_ == 0); | |
| 279 } | |
| 280 | |
| 281 // three children deep | |
| 282 // | |
| 283 // +e------------+ | |
| 284 // | +c1-------+ | | |
| 285 // | | +c2---+ | | | |
| 286 // | | | +c3-| | | | |
| 287 // | | | | | | | | |
| 288 // | | | +---| | | | |
| 289 // | | +-----+ | | | |
| 290 // | +---------+ | | |
| 291 // +-------------+ | |
| 292 // | |
| 293 | |
| 294 TEST_F(HitTestAggregatorTest, ThreeChildrenDeep) { | |
| 295 Reset(); | |
| 296 EXPECT_TRUE(count() == 0); | |
| 297 | |
| 298 cc::SurfaceId e_surface_id = MakeSurfaceId(kDisplayFrameSink, 1); | |
| 299 cc::SurfaceId c1_surface_id = MakeSurfaceId(kDisplayFrameSink, 2); | |
| 300 cc::SurfaceId c2_surface_id = MakeSurfaceId(kDisplayFrameSink, 3); | |
| 301 cc::SurfaceId c3_surface_id = MakeSurfaceId(kDisplayFrameSink, 4); | |
| 302 | |
| 303 auto e_hit_test_data = HitTestData::New(); | |
| 304 e_hit_test_data->surface_id_ = e_surface_id; | |
| 305 e_hit_test_data->bounds_.SetRect(0, 0, 800, 800); | |
| 306 | |
| 307 auto c1_hit_test_region = HitTestRegion::New(); | |
| 308 c1_hit_test_region->flags_ = HitTestRegionFlags::HIT_TEST_CHILD_SURFACE; | |
| 309 c1_hit_test_region->surface_id_ = c1_surface_id; | |
| 310 c1_hit_test_region->rect_.SetRect(100, 100, 700, 700); | |
| 311 | |
| 312 e_hit_test_data->regions_.push_back(std::move(c1_hit_test_region)); | |
| 313 | |
| 314 auto c1_hit_test_data = HitTestData::New(); | |
| 315 c1_hit_test_data->surface_id_ = c1_surface_id; | |
| 316 c1_hit_test_data->bounds_.SetRect(0, 0, 600, 600); | |
| 317 | |
| 318 auto c2_hit_test_region = HitTestRegion::New(); | |
| 319 c2_hit_test_region->flags_ = HitTestRegionFlags::HIT_TEST_CHILD_SURFACE; | |
| 320 c2_hit_test_region->surface_id_ = c2_surface_id; | |
| 321 c2_hit_test_region->rect_.SetRect(100, 100, 500, 500); | |
| 322 | |
| 323 c1_hit_test_data->regions_.push_back(std::move(c2_hit_test_region)); | |
| 324 | |
| 325 auto c2_hit_test_data = HitTestData::New(); | |
| 326 c2_hit_test_data->surface_id_ = c2_surface_id; | |
| 327 c2_hit_test_data->bounds_.SetRect(0, 0, 400, 400); | |
| 328 | |
| 329 auto c3_hit_test_region = HitTestRegion::New(); | |
| 330 c3_hit_test_region->flags_ = HitTestRegionFlags::HIT_TEST_CHILD_SURFACE; | |
| 331 c3_hit_test_region->surface_id_ = c3_surface_id; | |
| 332 c3_hit_test_region->rect_.SetRect(100, 100, 300, 300); | |
| 333 | |
| 334 c2_hit_test_data->regions_.push_back(std::move(c3_hit_test_region)); | |
| 335 | |
| 336 auto c3_hit_test_data = HitTestData::New(); | |
| 337 c3_hit_test_data->surface_id_ = c3_surface_id; | |
| 338 c3_hit_test_data->bounds_.SetRect(0, 0, 200, 200); | |
| 339 | |
| 340 // submit ( in unexpected order ) | |
| 341 | |
| 342 EXPECT_TRUE(GetPendingCount() == 0); | |
| 343 | |
| 344 aggregator_.SubmitHitTestData(std::move(c1_hit_test_data)); | |
| 345 EXPECT_TRUE(GetPendingCount() == 1); | |
| 346 | |
| 347 aggregator_.SubmitHitTestData(std::move(c3_hit_test_data)); | |
| 348 EXPECT_TRUE(GetPendingCount() == 2); | |
| 349 | |
| 350 aggregator_.SubmitHitTestData(std::move(e_hit_test_data)); | |
| 351 EXPECT_TRUE(GetPendingCount() == 3); | |
| 352 | |
| 353 aggregator_.SubmitHitTestData(std::move(c2_hit_test_data)); | |
| 354 EXPECT_TRUE(GetPendingCount() == 4); | |
| 355 | |
| 356 // surfaces added to DisplayFrame ( in unexpected order ) | |
| 357 | |
| 358 EXPECT_TRUE(count() == 0); | |
| 359 | |
| 360 EXPECT_TRUE(GetActiveCount() == 0); | |
| 361 | |
| 362 aggregator_.OnSurfaceWillDraw(c2_surface_id); | |
| 363 EXPECT_TRUE(GetActiveCount() == 1); | |
| 364 | |
| 365 aggregator_.OnSurfaceWillDraw(c1_surface_id); | |
| 366 EXPECT_TRUE(GetActiveCount() == 2); | |
| 367 | |
| 368 aggregator_.OnSurfaceWillDraw(e_surface_id); | |
| 369 EXPECT_TRUE(GetActiveCount() == 3); | |
| 370 | |
| 371 aggregator_.OnSurfaceWillDraw(c3_surface_id); | |
| 372 EXPECT_TRUE(GetActiveCount() == 4); | |
| 373 | |
| 374 // aggregate and swap | |
| 375 | |
| 376 aggregator_.Aggregate(e_surface_id); | |
| 377 EXPECT_TRUE(count() == 0); | |
| 378 | |
| 379 aggregator_.Swap(); | |
| 380 | |
| 381 // we expect 3 entries in the tree - one for each child | |
| 382 EXPECT_TRUE(count() == 6); | |
| 383 | |
| 384 DisplayHitTestRegion* region; | |
| 385 | |
| 386 region = RegionAtIndex(0); | |
| 387 EXPECT_TRUE(region->flags_ == HitTestRegionFlags::HIT_TEST_BOUNDS); | |
| 388 EXPECT_TRUE(region->frame_sink_id_ == e_surface_id.frame_sink_id()); | |
| 389 EXPECT_TRUE(region->rect_ == gfx::Rect(0, 0, 800, 800)); | |
| 390 EXPECT_TRUE(region->child_count_ == 5); | |
| 391 | |
| 392 region = RegionAtIndex(1); | |
| 393 EXPECT_TRUE(region->flags_ == HitTestRegionFlags::HIT_TEST_CHILD_SURFACE); | |
| 394 EXPECT_TRUE(region->frame_sink_id_ == c1_surface_id.frame_sink_id()); | |
| 395 EXPECT_TRUE(region->rect_ == gfx::Rect(100, 100, 700, 700)); | |
| 396 EXPECT_TRUE(region->child_count_ == 4); | |
| 397 | |
| 398 region = RegionAtIndex(2); | |
| 399 EXPECT_TRUE(region->flags_ == HitTestRegionFlags::HIT_TEST_BOUNDS); | |
| 400 EXPECT_TRUE(region->frame_sink_id_ == c1_surface_id.frame_sink_id()); | |
| 401 EXPECT_TRUE(region->rect_ == gfx::Rect(0, 0, 600, 600)); | |
| 402 EXPECT_TRUE(region->child_count_ == 3); | |
| 403 | |
| 404 region = RegionAtIndex(3); | |
| 405 EXPECT_TRUE(region->flags_ == HitTestRegionFlags::HIT_TEST_CHILD_SURFACE); | |
| 406 EXPECT_TRUE(region->frame_sink_id_ == c2_surface_id.frame_sink_id()); | |
| 407 EXPECT_TRUE(region->rect_ == gfx::Rect(100, 100, 500, 500)); | |
| 408 EXPECT_TRUE(region->child_count_ == 2); | |
| 409 | |
| 410 region = RegionAtIndex(4); | |
| 411 EXPECT_TRUE(region->flags_ == HitTestRegionFlags::HIT_TEST_BOUNDS); | |
| 412 EXPECT_TRUE(region->frame_sink_id_ == c2_surface_id.frame_sink_id()); | |
| 413 EXPECT_TRUE(region->rect_ == gfx::Rect(0, 0, 400, 400)); | |
| 414 EXPECT_TRUE(region->child_count_ == 1); | |
| 415 | |
| 416 region = RegionAtIndex(5); | |
| 417 EXPECT_TRUE(region->flags_ == HitTestRegionFlags::HIT_TEST_CHILD_SURFACE); | |
| 418 EXPECT_TRUE(region->frame_sink_id_ == c3_surface_id.frame_sink_id()); | |
| 419 EXPECT_TRUE(region->rect_ == gfx::Rect(100, 100, 300, 300)); | |
| 420 EXPECT_TRUE(region->child_count_ == 0); | |
| 421 } | |
| 422 | |
| 423 // occluded child frame ( OOPIF ) | |
| 424 // | |
| 425 // +e-----------+ | |
| 426 // | +c--+ | | |
| 427 // | | +div-+ | | |
| 428 // | | | | | | |
| 429 // | | +----+ | | |
| 430 // | +---+ | | |
| 431 // +------------+ | |
| 432 // | |
| 433 | |
| 434 TEST_F(HitTestAggregatorTest, OccludedChildFrame) { | |
| 435 Reset(); | |
| 436 EXPECT_TRUE(count() == 0); | |
| 437 | |
| 438 cc::SurfaceId e_surface_id = MakeSurfaceId(kDisplayFrameSink, 1); | |
| 439 cc::SurfaceId c_surface_id = MakeSurfaceId(kDisplayFrameSink, 2); | |
| 440 | |
| 441 auto e_hit_test_data = HitTestData::New(); | |
| 442 e_hit_test_data->surface_id_ = e_surface_id; | |
| 443 e_hit_test_data->bounds_.SetRect(0, 0, 500, 500); | |
| 444 | |
| 445 auto div_hit_test_region = HitTestRegion::New(); | |
| 446 div_hit_test_region->flags_ = HitTestRegionFlags::HIT_TEST_MINE; | |
| 447 div_hit_test_region->rect_.SetRect(100, 100, 400, 400); | |
| 448 | |
| 449 auto c_hit_test_region = HitTestRegion::New(); | |
| 450 c_hit_test_region->flags_ = HitTestRegionFlags::HIT_TEST_CHILD_SURFACE; | |
| 451 c_hit_test_region->surface_id_ = c_surface_id; | |
| 452 c_hit_test_region->rect_.SetRect(200, 200, 500, 200); | |
| 453 | |
| 454 e_hit_test_data->regions_.push_back(std::move(div_hit_test_region)); | |
| 455 e_hit_test_data->regions_.push_back(std::move(c_hit_test_region)); | |
| 456 | |
| 457 auto c_hit_test_data = HitTestData::New(); | |
| 458 c_hit_test_data->surface_id_ = c_surface_id; | |
| 459 c_hit_test_data->bounds_.SetRect(0, 0, 300, 300); | |
| 460 | |
| 461 // submit ( in unexpected order ) | |
| 462 | |
| 463 EXPECT_TRUE(GetPendingCount() == 0); | |
| 464 | |
| 465 aggregator_.SubmitHitTestData(std::move(c_hit_test_data)); | |
| 466 EXPECT_TRUE(GetPendingCount() == 1); | |
| 467 | |
| 468 aggregator_.SubmitHitTestData(std::move(e_hit_test_data)); | |
| 469 EXPECT_TRUE(GetPendingCount() == 2); | |
| 470 | |
| 471 // surfaces added to DisplayFrame ( in unexpected order ) | |
| 472 | |
| 473 EXPECT_TRUE(count() == 0); | |
| 474 | |
| 475 EXPECT_TRUE(GetActiveCount() == 0); | |
| 476 | |
| 477 aggregator_.OnSurfaceWillDraw(e_surface_id); | |
| 478 EXPECT_TRUE(GetActiveCount() == 1); | |
| 479 | |
| 480 aggregator_.OnSurfaceWillDraw(c_surface_id); | |
| 481 EXPECT_TRUE(GetActiveCount() == 2); | |
| 482 | |
| 483 // aggregate and swap | |
| 484 | |
| 485 aggregator_.Aggregate(e_surface_id); | |
| 486 EXPECT_TRUE(count() == 0); | |
| 487 | |
| 488 aggregator_.Swap(); | |
| 489 | |
| 490 EXPECT_TRUE(count() == 3); | |
| 491 | |
| 492 DisplayHitTestRegion* region; | |
| 493 | |
| 494 region = RegionAtIndex(0); | |
| 495 EXPECT_TRUE(region->flags_ == HitTestRegionFlags::HIT_TEST_BOUNDS); | |
| 496 EXPECT_TRUE(region->frame_sink_id_ == e_surface_id.frame_sink_id()); | |
| 497 EXPECT_TRUE(region->rect_ == gfx::Rect(0, 0, 500, 500)); | |
| 498 EXPECT_TRUE(region->child_count_ == 2); | |
| 499 | |
| 500 region = RegionAtIndex(1); | |
|
rjkroege
2017/06/07 21:19:06
I would expect an additional region typically yes?
gklassen
2017/06/08 20:33:22
Will update based on conversation this morning.
rjkroege
2017/06/09 15:47:07
could type "done" using the handy button to mean t
gklassen
2017/06/12 16:30:41
Done.
| |
| 501 EXPECT_TRUE(region->rect_ == gfx::Rect(100, 100, 400, 400)); | |
| 502 EXPECT_TRUE(region->flags_ == HitTestRegionFlags::HIT_TEST_MINE); | |
| 503 EXPECT_TRUE(region->child_count_ == 0); | |
| 504 | |
| 505 region = RegionAtIndex(2); | |
| 506 EXPECT_TRUE(region->rect_ == gfx::Rect(200, 200, 500, 200)); | |
| 507 EXPECT_TRUE(region->frame_sink_id_ == c_surface_id.frame_sink_id()); | |
| 508 EXPECT_TRUE(region->flags_ == HitTestRegionFlags::HIT_TEST_CHILD_SURFACE); | |
| 509 EXPECT_TRUE(region->child_count_ == 0); | |
| 510 } | |
| 511 | |
| 512 } // namespace test | |
| 513 } // namespace hit_test | |
| 514 } // namespace viz | |
| OLD | NEW |