Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2011 The Chromium Authors. All rights reserved. | 1 // Copyright 2011 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 "cc/trees/layer_tree_host_impl.h" | 5 #include "cc/trees/layer_tree_host_impl.h" |
| 6 | 6 |
| 7 #include <cmath> | 7 #include <cmath> |
| 8 | 8 |
| 9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
| (...skipping 7411 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 7422 host_impl_->Animate(start_time + base::TimeDelta::FromMilliseconds(250)); | 7422 host_impl_->Animate(start_time + base::TimeDelta::FromMilliseconds(250)); |
| 7423 host_impl_->UpdateAnimationState(true); | 7423 host_impl_->UpdateAnimationState(true); |
| 7424 | 7424 |
| 7425 EXPECT_VECTOR_EQ(gfx::ScrollOffset(0, 100), | 7425 EXPECT_VECTOR_EQ(gfx::ScrollOffset(0, 100), |
| 7426 scrolling_layer->TotalScrollOffset()); | 7426 scrolling_layer->TotalScrollOffset()); |
| 7427 EXPECT_EQ(NULL, host_impl_->CurrentlyScrollingLayer()); | 7427 EXPECT_EQ(NULL, host_impl_->CurrentlyScrollingLayer()); |
| 7428 } | 7428 } |
| 7429 | 7429 |
| 7430 TEST_F(LayerTreeHostImplTest, GetPictureLayerImplPairs) { | 7430 TEST_F(LayerTreeHostImplTest, GetPictureLayerImplPairs) { |
| 7431 host_impl_->CreatePendingTree(); | 7431 host_impl_->CreatePendingTree(); |
| 7432 host_impl_->ActivateSyncTree(); | 7432 host_impl_->pending_tree()->SetRootLayer( |
| 7433 host_impl_->CreatePendingTree(); | 7433 PictureLayerImpl::Create(host_impl_->pending_tree(), 10)); |
| 7434 | 7434 |
| 7435 LayerTreeImpl* active_tree = host_impl_->active_tree(); | |
| 7436 LayerTreeImpl* pending_tree = host_impl_->pending_tree(); | 7435 LayerTreeImpl* pending_tree = host_impl_->pending_tree(); |
| 7437 EXPECT_NE(active_tree, pending_tree); | 7436 LayerImpl* pending_layer = pending_tree->root_layer(); |
| 7438 | |
| 7439 scoped_ptr<FakePictureLayerImpl> active_layer = | |
| 7440 FakePictureLayerImpl::Create(active_tree, 10); | |
| 7441 scoped_ptr<FakePictureLayerImpl> pending_layer = | |
| 7442 FakePictureLayerImpl::Create(pending_tree, 10); | |
| 7443 | 7437 |
| 7444 std::vector<PictureLayerImpl::Pair> layer_pairs; | 7438 std::vector<PictureLayerImpl::Pair> layer_pairs; |
| 7445 host_impl_->GetPictureLayerImplPairs(&layer_pairs); | 7439 host_impl_->GetPictureLayerImplPairs(&layer_pairs); |
| 7440 EXPECT_EQ(1u, layer_pairs.size()); | |
| 7441 EXPECT_EQ(pending_layer, layer_pairs[0].pending); | |
| 7442 EXPECT_EQ(nullptr, layer_pairs[0].active); | |
| 7446 | 7443 |
| 7447 EXPECT_EQ(2u, layer_pairs.size()); | 7444 host_impl_->ActivateSyncTree(); |
|
vmpstr
2014/10/24 16:47:05
Can you add another test here that tests active la
danakj
2014/10/24 16:53:30
Yep!
| |
| 7448 if (layer_pairs[0].active) { | |
| 7449 EXPECT_EQ(active_layer.get(), layer_pairs[0].active); | |
| 7450 EXPECT_EQ(NULL, layer_pairs[0].pending); | |
| 7451 } else { | |
| 7452 EXPECT_EQ(pending_layer.get(), layer_pairs[0].pending); | |
| 7453 EXPECT_EQ(NULL, layer_pairs[0].active); | |
| 7454 } | |
| 7455 | 7445 |
| 7456 if (layer_pairs[1].active) { | 7446 LayerTreeImpl* active_tree = host_impl_->active_tree(); |
| 7457 EXPECT_EQ(active_layer.get(), layer_pairs[1].active); | 7447 LayerImpl* active_layer = active_tree->root_layer(); |
| 7458 EXPECT_EQ(NULL, layer_pairs[1].pending); | 7448 EXPECT_NE(active_tree, pending_tree); |
| 7459 } else { | 7449 EXPECT_NE(active_layer, pending_layer); |
| 7460 EXPECT_EQ(pending_layer.get(), layer_pairs[1].pending); | 7450 EXPECT_NE(nullptr, active_tree); |
| 7461 EXPECT_EQ(NULL, layer_pairs[1].active); | 7451 EXPECT_NE(nullptr, active_layer); |
| 7462 } | |
| 7463 | 7452 |
| 7464 active_layer->set_twin_layer(pending_layer.get()); | 7453 host_impl_->CreatePendingTree(); |
| 7465 pending_layer->set_twin_layer(active_layer.get()); | |
| 7466 | 7454 |
| 7467 layer_pairs.clear(); | 7455 layer_pairs.clear(); |
| 7468 host_impl_->GetPictureLayerImplPairs(&layer_pairs); | 7456 host_impl_->GetPictureLayerImplPairs(&layer_pairs); |
| 7469 EXPECT_EQ(1u, layer_pairs.size()); | 7457 EXPECT_EQ(1u, layer_pairs.size()); |
| 7458 EXPECT_EQ(active_layer, layer_pairs[0].active); | |
| 7459 EXPECT_EQ(pending_layer, layer_pairs[0].pending); | |
| 7470 | 7460 |
| 7471 EXPECT_EQ(active_layer.get(), layer_pairs[0].active); | 7461 // Activate, the active layer has no twin now. |
| 7472 EXPECT_EQ(pending_layer.get(), layer_pairs[0].pending); | 7462 host_impl_->ActivateSyncTree(); |
| 7463 | |
| 7464 layer_pairs.clear(); | |
| 7465 host_impl_->GetPictureLayerImplPairs(&layer_pairs); | |
| 7466 EXPECT_EQ(1u, layer_pairs.size()); | |
| 7467 EXPECT_EQ(active_layer, layer_pairs[0].active); | |
| 7468 EXPECT_EQ(nullptr, layer_pairs[0].pending); | |
| 7473 } | 7469 } |
| 7474 | 7470 |
| 7475 TEST_F(LayerTreeHostImplTest, DidBecomeActive) { | 7471 TEST_F(LayerTreeHostImplTest, DidBecomeActive) { |
| 7476 host_impl_->CreatePendingTree(); | 7472 host_impl_->CreatePendingTree(); |
| 7477 host_impl_->ActivateSyncTree(); | 7473 host_impl_->ActivateSyncTree(); |
| 7478 host_impl_->CreatePendingTree(); | 7474 host_impl_->CreatePendingTree(); |
| 7479 | 7475 |
| 7480 LayerTreeImpl* pending_tree = host_impl_->pending_tree(); | 7476 LayerTreeImpl* pending_tree = host_impl_->pending_tree(); |
| 7481 | 7477 |
| 7482 scoped_ptr<FakePictureLayerImpl> pending_layer = | 7478 scoped_ptr<FakePictureLayerImpl> pending_layer = |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 7538 // surface. | 7534 // surface. |
| 7539 EXPECT_EQ(0, num_lost_surfaces_); | 7535 EXPECT_EQ(0, num_lost_surfaces_); |
| 7540 host_impl_->DidLoseOutputSurface(); | 7536 host_impl_->DidLoseOutputSurface(); |
| 7541 EXPECT_EQ(1, num_lost_surfaces_); | 7537 EXPECT_EQ(1, num_lost_surfaces_); |
| 7542 host_impl_->DidLoseOutputSurface(); | 7538 host_impl_->DidLoseOutputSurface(); |
| 7543 EXPECT_LE(1, num_lost_surfaces_); | 7539 EXPECT_LE(1, num_lost_surfaces_); |
| 7544 } | 7540 } |
| 7545 | 7541 |
| 7546 } // namespace | 7542 } // namespace |
| 7547 } // namespace cc | 7543 } // namespace cc |
| OLD | NEW |