Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(909)

Side by Side Diff: cc/trees/layer_tree_host_impl_unittest.cc

Issue 680793002: Revert two cc patches due to crashes on canary. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Revert both patches Created 6 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « cc/trees/layer_tree_host_impl.cc ('k') | cc/trees/layer_tree_host_unittest_picture.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 <algorithm>
8 #include <cmath> 7 #include <cmath>
9 8
10 #include "base/bind.h" 9 #include "base/bind.h"
11 #include "base/command_line.h" 10 #include "base/command_line.h"
12 #include "base/containers/hash_tables.h" 11 #include "base/containers/hash_tables.h"
13 #include "base/containers/scoped_ptr_hash_map.h" 12 #include "base/containers/scoped_ptr_hash_map.h"
14 #include "cc/animation/scrollbar_animation_controller_thinning.h" 13 #include "cc/animation/scrollbar_animation_controller_thinning.h"
15 #include "cc/base/latency_info_swap_promise.h" 14 #include "cc/base/latency_info_swap_promise.h"
16 #include "cc/base/math_util.h" 15 #include "cc/base/math_util.h"
17 #include "cc/input/page_scale_animation.h" 16 #include "cc/input/page_scale_animation.h"
(...skipping 7419 matching lines...) Expand 10 before | Expand all | Expand 10 after
7437 host_impl_->Animate(start_time + base::TimeDelta::FromMilliseconds(250)); 7436 host_impl_->Animate(start_time + base::TimeDelta::FromMilliseconds(250));
7438 host_impl_->UpdateAnimationState(true); 7437 host_impl_->UpdateAnimationState(true);
7439 7438
7440 EXPECT_VECTOR_EQ(gfx::ScrollOffset(0, 100), 7439 EXPECT_VECTOR_EQ(gfx::ScrollOffset(0, 100),
7441 scrolling_layer->TotalScrollOffset()); 7440 scrolling_layer->TotalScrollOffset());
7442 EXPECT_EQ(NULL, host_impl_->CurrentlyScrollingLayer()); 7441 EXPECT_EQ(NULL, host_impl_->CurrentlyScrollingLayer());
7443 } 7442 }
7444 7443
7445 TEST_F(LayerTreeHostImplTest, GetPictureLayerImplPairs) { 7444 TEST_F(LayerTreeHostImplTest, GetPictureLayerImplPairs) {
7446 host_impl_->CreatePendingTree(); 7445 host_impl_->CreatePendingTree();
7447 host_impl_->pending_tree()->SetRootLayer( 7446 host_impl_->ActivateSyncTree();
7448 PictureLayerImpl::Create(host_impl_->pending_tree(), 10)); 7447 host_impl_->CreatePendingTree();
7449 7448
7449 LayerTreeImpl* active_tree = host_impl_->active_tree();
7450 LayerTreeImpl* pending_tree = host_impl_->pending_tree(); 7450 LayerTreeImpl* pending_tree = host_impl_->pending_tree();
7451 LayerImpl* pending_layer = pending_tree->root_layer(); 7451 EXPECT_NE(active_tree, pending_tree);
7452
7453 scoped_ptr<FakePictureLayerImpl> active_layer =
7454 FakePictureLayerImpl::Create(active_tree, 10);
7455 scoped_ptr<FakePictureLayerImpl> pending_layer =
7456 FakePictureLayerImpl::Create(pending_tree, 10);
7452 7457
7453 std::vector<PictureLayerImpl::Pair> layer_pairs; 7458 std::vector<PictureLayerImpl::Pair> layer_pairs;
7454 host_impl_->GetPictureLayerImplPairs(&layer_pairs); 7459 host_impl_->GetPictureLayerImplPairs(&layer_pairs);
7455 EXPECT_EQ(1u, layer_pairs.size());
7456 EXPECT_EQ(pending_layer, layer_pairs[0].pending);
7457 EXPECT_EQ(nullptr, layer_pairs[0].active);
7458 7460
7459 host_impl_->ActivateSyncTree(); 7461 EXPECT_EQ(2u, layer_pairs.size());
7462 if (layer_pairs[0].active) {
7463 EXPECT_EQ(active_layer.get(), layer_pairs[0].active);
7464 EXPECT_EQ(NULL, layer_pairs[0].pending);
7465 } else {
7466 EXPECT_EQ(pending_layer.get(), layer_pairs[0].pending);
7467 EXPECT_EQ(NULL, layer_pairs[0].active);
7468 }
7460 7469
7461 LayerTreeImpl* active_tree = host_impl_->active_tree(); 7470 if (layer_pairs[1].active) {
7462 LayerImpl* active_layer = active_tree->root_layer(); 7471 EXPECT_EQ(active_layer.get(), layer_pairs[1].active);
7463 EXPECT_NE(active_tree, pending_tree); 7472 EXPECT_EQ(NULL, layer_pairs[1].pending);
7464 EXPECT_NE(active_layer, pending_layer); 7473 } else {
7465 EXPECT_NE(nullptr, active_tree); 7474 EXPECT_EQ(pending_layer.get(), layer_pairs[1].pending);
7466 EXPECT_NE(nullptr, active_layer); 7475 EXPECT_EQ(NULL, layer_pairs[1].active);
7476 }
7467 7477
7468 host_impl_->CreatePendingTree(); 7478 active_layer->set_twin_layer(pending_layer.get());
7479 pending_layer->set_twin_layer(active_layer.get());
7469 7480
7470 layer_pairs.clear(); 7481 layer_pairs.clear();
7471 host_impl_->GetPictureLayerImplPairs(&layer_pairs); 7482 host_impl_->GetPictureLayerImplPairs(&layer_pairs);
7472 EXPECT_EQ(1u, layer_pairs.size()); 7483 EXPECT_EQ(1u, layer_pairs.size());
7473 EXPECT_EQ(active_layer, layer_pairs[0].active);
7474 EXPECT_EQ(pending_layer, layer_pairs[0].pending);
7475 7484
7476 // Activate, the active layer has no twin now. 7485 EXPECT_EQ(active_layer.get(), layer_pairs[0].active);
7477 host_impl_->ActivateSyncTree(); 7486 EXPECT_EQ(pending_layer.get(), layer_pairs[0].pending);
7478
7479 layer_pairs.clear();
7480 host_impl_->GetPictureLayerImplPairs(&layer_pairs);
7481 EXPECT_EQ(1u, layer_pairs.size());
7482 EXPECT_EQ(active_layer, layer_pairs[0].active);
7483 EXPECT_EQ(nullptr, layer_pairs[0].pending);
7484
7485 // Create another layer in the pending tree that's not in the active tree. We
7486 // should get two pairs.
7487 host_impl_->CreatePendingTree();
7488 host_impl_->pending_tree()->root_layer()->AddChild(
7489 PictureLayerImpl::Create(host_impl_->pending_tree(), 11));
7490
7491 LayerImpl* new_pending_layer = pending_tree->root_layer()->children()[0];
7492
7493 layer_pairs.clear();
7494 host_impl_->GetPictureLayerImplPairs(&layer_pairs);
7495 EXPECT_EQ(2u, layer_pairs.size());
7496
7497 // The pair ordering is flaky, so make it consistent.
7498 if (layer_pairs[0].active != active_layer)
7499 std::swap(layer_pairs[0], layer_pairs[1]);
7500
7501 EXPECT_EQ(active_layer, layer_pairs[0].active);
7502 EXPECT_EQ(pending_layer, layer_pairs[0].pending);
7503 EXPECT_EQ(new_pending_layer, layer_pairs[1].pending);
7504 EXPECT_EQ(nullptr, layer_pairs[1].active);
7505 } 7487 }
7506 7488
7507 TEST_F(LayerTreeHostImplTest, DidBecomeActive) { 7489 TEST_F(LayerTreeHostImplTest, DidBecomeActive) {
7508 host_impl_->CreatePendingTree(); 7490 host_impl_->CreatePendingTree();
7509 host_impl_->ActivateSyncTree(); 7491 host_impl_->ActivateSyncTree();
7510 host_impl_->CreatePendingTree(); 7492 host_impl_->CreatePendingTree();
7511 7493
7512 LayerTreeImpl* pending_tree = host_impl_->pending_tree(); 7494 LayerTreeImpl* pending_tree = host_impl_->pending_tree();
7513 7495
7514 scoped_ptr<FakePictureLayerImpl> pending_layer = 7496 scoped_ptr<FakePictureLayerImpl> pending_layer =
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
7570 // surface. 7552 // surface.
7571 EXPECT_EQ(0, num_lost_surfaces_); 7553 EXPECT_EQ(0, num_lost_surfaces_);
7572 host_impl_->DidLoseOutputSurface(); 7554 host_impl_->DidLoseOutputSurface();
7573 EXPECT_EQ(1, num_lost_surfaces_); 7555 EXPECT_EQ(1, num_lost_surfaces_);
7574 host_impl_->DidLoseOutputSurface(); 7556 host_impl_->DidLoseOutputSurface();
7575 EXPECT_LE(1, num_lost_surfaces_); 7557 EXPECT_LE(1, num_lost_surfaces_);
7576 } 7558 }
7577 7559
7578 } // namespace 7560 } // namespace
7579 } // namespace cc 7561 } // namespace cc
OLDNEW
« no previous file with comments | « cc/trees/layer_tree_host_impl.cc ('k') | cc/trees/layer_tree_host_unittest_picture.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698