Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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/compiler_specific.h" | 5 #include "base/compiler_specific.h" |
| 6 #include "base/macros.h" | 6 #include "base/macros.h" |
| 7 #include "cc/test/fake_content_layer_client.h" | 7 #include "cc/test/fake_content_layer_client.h" |
| 8 #include "cc/test/fake_picture_layer.h" | 8 #include "cc/test/fake_picture_layer.h" |
| 9 #include "cc/test/layer_tree_test.h" | 9 #include "cc/test/layer_tree_test.h" |
| 10 #include "cc/trees/proxy_impl.h" | 10 #include "cc/trees/proxy_impl.h" |
| (...skipping 300 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 311 | 311 |
| 312 private: | 312 private: |
| 313 base::Lock activate_blocked_lock_; | 313 base::Lock activate_blocked_lock_; |
| 314 bool activate_blocked_ = false; | 314 bool activate_blocked_ = false; |
| 315 | 315 |
| 316 DISALLOW_COPY_AND_ASSIGN(LayerTreeHostProxyTestCommitWaitsForActivation); | 316 DISALLOW_COPY_AND_ASSIGN(LayerTreeHostProxyTestCommitWaitsForActivation); |
| 317 }; | 317 }; |
| 318 | 318 |
| 319 MULTI_THREAD_TEST_F(LayerTreeHostProxyTestCommitWaitsForActivation); | 319 MULTI_THREAD_TEST_F(LayerTreeHostProxyTestCommitWaitsForActivation); |
| 320 | 320 |
| 321 // Test for a corner case of main frame before activation (MFBA) and commit | |
| 322 // waits for activation. If a commit (with wait for activation flag set) | |
| 323 // is ready before the activation for a previous commit then the activation | |
| 324 // should not signal the completion event of the second commit. | |
|
brianderson
2017/04/17 22:26:33
Looks like this comment was accidentally removed.
panicker
2017/04/17 22:53:29
Done.
| |
| 325 class LayerTreeHostProxyTestCommitWaitsForActivationMFBA | 321 class LayerTreeHostProxyTestCommitWaitsForActivationMFBA |
| 326 : public LayerTreeHostProxyTest { | 322 : public LayerTreeHostProxyTest { |
| 327 protected: | 323 protected: |
| 328 LayerTreeHostProxyTestCommitWaitsForActivationMFBA() = default; | 324 LayerTreeHostProxyTestCommitWaitsForActivationMFBA() = default; |
| 329 | 325 |
| 330 void InitializeSettings(LayerTreeSettings* settings) override { | 326 void InitializeSettings(LayerTreeSettings* settings) override { |
| 331 settings->main_frame_before_activation_enabled = true; | 327 settings->main_frame_before_activation_enabled = true; |
| 332 LayerTreeHostProxyTest::InitializeSettings(settings); | 328 LayerTreeHostProxyTest::InitializeSettings(settings); |
| 333 } | 329 } |
| 334 | 330 |
| (...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 413 | 409 |
| 414 private: | 410 private: |
| 415 base::Lock activate_blocked_lock_; | 411 base::Lock activate_blocked_lock_; |
| 416 bool activate_blocked_ = false; | 412 bool activate_blocked_ = false; |
| 417 | 413 |
| 418 DISALLOW_COPY_AND_ASSIGN(LayerTreeHostProxyTestCommitWaitsForActivationMFBA); | 414 DISALLOW_COPY_AND_ASSIGN(LayerTreeHostProxyTestCommitWaitsForActivationMFBA); |
| 419 }; | 415 }; |
| 420 | 416 |
| 421 MULTI_THREAD_TEST_F(LayerTreeHostProxyTestCommitWaitsForActivationMFBA); | 417 MULTI_THREAD_TEST_F(LayerTreeHostProxyTestCommitWaitsForActivationMFBA); |
| 422 | 418 |
| 419 // Test for activation time passed in BeginFrameArgs. | |
| 420 class LayerTreeHostProxyTestActivationTime : public LayerTreeHostProxyTest { | |
| 421 protected: | |
| 422 LayerTreeHostProxyTestActivationTime() = default; | |
| 423 | |
| 424 void BeginTest() override { PostSetNeedsCommitToMainThread(); } | |
| 425 | |
| 426 void InitializeSettings(LayerTreeSettings* settings) override { | |
| 427 settings->main_frame_before_activation_enabled = true; | |
| 428 LayerTreeHostProxyTest::InitializeSettings(settings); | |
| 429 } | |
| 430 | |
| 431 void DidSendBeginMainFrameOnThread(LayerTreeHostImpl* impl) override { | |
| 432 if (activate_blocked_) { | |
| 433 impl->BlockNotifyReadyToActivateForTesting(false); | |
| 434 { | |
| 435 base::AutoLock hold(activate_blocked_lock_); | |
| 436 activate_blocked_ = false; | |
| 437 } | |
| 438 } | |
| 439 } | |
| 440 | |
| 441 void BeginMainFrame(const BeginFrameArgs& args) override { | |
| 442 { | |
| 443 base::AutoLock hold(activate_blocked_lock_); | |
| 444 EXPECT_FALSE(activate_blocked_); | |
|
brianderson
2017/04/17 22:26:33
Only expect during case 1.
panicker
2017/04/17 22:53:29
Acknowledged.
| |
| 445 } | |
| 446 switch (args.source_frame_number) { | |
| 447 case 0: | |
| 448 // Initial frame, no activation yet. | |
| 449 EXPECT_EQ(0UL, args.ready_to_activate_time.size()); | |
| 450 break; | |
| 451 case 1: | |
| 452 // Frame #1, activation is delayed in BeginCommitOnThread. | |
| 453 EXPECT_EQ(0UL, args.ready_to_activate_time.size()); | |
| 454 break; | |
| 455 case 2: | |
| 456 // Frame #2, activation is delayed in BeginCommitOnThread. | |
| 457 EXPECT_EQ(0UL, args.ready_to_activate_time.size()); | |
| 458 break; | |
| 459 case 3: | |
| 460 // Frame #3, received activation for first two frames. | |
| 461 EXPECT_EQ(2UL, args.ready_to_activate_time.size()); | |
| 462 EXPECT_EQ(1UL, args.ready_to_activate_time[0].first); | |
|
panicker
2017/04/17 21:54:50
Hmm I think I expected this to be #0 vs. #1?
brianderson
2017/04/17 22:26:33
I think case 1 should have the #0 and case 3 shoul
panicker
2017/04/17 22:53:29
Acknowledged.
| |
| 463 EXPECT_EQ(2UL, args.ready_to_activate_time[1].first); | |
| 464 EndTest(); | |
| 465 } | |
| 466 } | |
| 467 | |
| 468 void DidActivateTreeOnThread(LayerTreeHostImpl* impl) override { | |
| 469 if (impl->sync_tree()->source_frame_number() == 2) | |
|
brianderson
2017/04/17 22:26:33
|| source_frame_number == 0.
panicker
2017/04/17 22:53:29
Done.
| |
| 470 PostSetNeedsCommitToMainThread(); // invoke for frame 3 | |
| 471 } | |
| 472 | |
| 473 void BeginCommitOnThread(LayerTreeHostImpl* impl) override { | |
| 474 // Block activation for the first two frames | |
| 475 // and invoke PostSetNeedsCommitToMainThread for frame 1, 2 | |
| 476 if (impl->sync_tree()->source_frame_number() <= 0) { | |
|
brianderson
2017/04/17 22:26:33
Change the method override to CommitCompleteOnThre
panicker
2017/04/17 22:53:29
Done.
| |
| 477 impl->BlockNotifyReadyToActivateForTesting(true); | |
| 478 PostSetNeedsCommitToMainThread(); | |
| 479 { | |
| 480 base::AutoLock hold(activate_blocked_lock_); | |
| 481 activate_blocked_ = true; | |
| 482 } | |
| 483 } | |
| 484 } | |
| 485 | |
| 486 void AfterTest() override {} | |
| 487 | |
| 488 private: | |
| 489 base::Lock activate_blocked_lock_; | |
| 490 bool activate_blocked_ = false; | |
| 491 | |
| 492 DISALLOW_COPY_AND_ASSIGN(LayerTreeHostProxyTestActivationTime); | |
| 493 }; | |
| 494 | |
| 495 MULTI_THREAD_TEST_F(LayerTreeHostProxyTestActivationTime); | |
| 496 | |
| 423 } // namespace cc | 497 } // namespace cc |
| OLD | NEW |