| 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 402 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 413 | 413 |
| 414 private: | 414 private: |
| 415 base::Lock activate_blocked_lock_; | 415 base::Lock activate_blocked_lock_; |
| 416 bool activate_blocked_ = false; | 416 bool activate_blocked_ = false; |
| 417 | 417 |
| 418 DISALLOW_COPY_AND_ASSIGN(LayerTreeHostProxyTestCommitWaitsForActivationMFBA); | 418 DISALLOW_COPY_AND_ASSIGN(LayerTreeHostProxyTestCommitWaitsForActivationMFBA); |
| 419 }; | 419 }; |
| 420 | 420 |
| 421 MULTI_THREAD_TEST_F(LayerTreeHostProxyTestCommitWaitsForActivationMFBA); | 421 MULTI_THREAD_TEST_F(LayerTreeHostProxyTestCommitWaitsForActivationMFBA); |
| 422 | 422 |
| 423 // Test for activation time passed in BeginFrameArgs. | |
| 424 class LayerTreeHostProxyTestActivationTime : public LayerTreeHostProxyTest { | |
| 425 protected: | |
| 426 LayerTreeHostProxyTestActivationTime() = default; | |
| 427 | |
| 428 void BeginTest() override { PostSetNeedsCommitToMainThread(); } | |
| 429 | |
| 430 void InitializeSettings(LayerTreeSettings* settings) override { | |
| 431 settings->main_frame_before_activation_enabled = true; | |
| 432 LayerTreeHostProxyTest::InitializeSettings(settings); | |
| 433 } | |
| 434 | |
| 435 void DidSendBeginMainFrameOnThread(LayerTreeHostImpl* impl) override { | |
| 436 if (activate_blocked_) { | |
| 437 impl->BlockNotifyReadyToActivateForTesting(false); | |
| 438 { | |
| 439 base::AutoLock hold(activate_blocked_lock_); | |
| 440 activate_blocked_ = false; | |
| 441 } | |
| 442 } | |
| 443 } | |
| 444 | |
| 445 void BeginMainFrame(const BeginFrameArgs& args) override { | |
| 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 for Frame #0. | |
| 453 EXPECT_EQ(1UL, args.ready_to_activate_time.size()); | |
| 454 EXPECT_EQ(0UL, args.ready_to_activate_time[0].first); | |
| 455 break; | |
| 456 case 2: | |
| 457 // Frame #2, activation is delayed in BeginCommitOnThread. | |
| 458 EXPECT_EQ(0UL, args.ready_to_activate_time.size()); | |
| 459 break; | |
| 460 case 3: | |
| 461 // Frame #3, received activation for Frame #1 & #2. | |
| 462 EXPECT_EQ(2UL, args.ready_to_activate_time.size()); | |
| 463 EXPECT_EQ(1UL, args.ready_to_activate_time[0].first); | |
| 464 EXPECT_EQ(2UL, args.ready_to_activate_time[1].first); | |
| 465 EndTest(); | |
| 466 } | |
| 467 } | |
| 468 | |
| 469 void DidActivateTreeOnThread(LayerTreeHostImpl* impl) override { | |
| 470 if (impl->sync_tree()->source_frame_number() == 0 || | |
| 471 impl->sync_tree()->source_frame_number() == 2) | |
| 472 PostSetNeedsCommitToMainThread(); // invoke for Frame #3 | |
| 473 } | |
| 474 | |
| 475 void CommitCompleteOnThread(LayerTreeHostImpl* impl) override { | |
| 476 // Block activation for Frame #1 | |
| 477 if (impl->sync_tree()->source_frame_number() == 1) { | |
| 478 impl->BlockNotifyReadyToActivateForTesting(true); | |
| 479 PostSetNeedsCommitToMainThread(); | |
| 480 { | |
| 481 base::AutoLock hold(activate_blocked_lock_); | |
| 482 activate_blocked_ = true; | |
| 483 } | |
| 484 } | |
| 485 } | |
| 486 | |
| 487 void AfterTest() override {} | |
| 488 | |
| 489 private: | |
| 490 base::Lock activate_blocked_lock_; | |
| 491 bool activate_blocked_ = false; | |
| 492 | |
| 493 DISALLOW_COPY_AND_ASSIGN(LayerTreeHostProxyTestActivationTime); | |
| 494 }; | |
| 495 | |
| 496 MULTI_THREAD_TEST_F(LayerTreeHostProxyTestActivationTime); | |
| 497 | |
| 498 } // namespace cc | 423 } // namespace cc |
| OLD | NEW |