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

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

Issue 393713002: Scroll offset animation curve retargeting. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Remove workaround. Created 6 years, 5 months 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 | Annotate | Revision Log
« no previous file with comments | « cc/trees/layer_tree_host_impl.cc ('k') | ui/gfx/geometry/cubic_bezier.h » ('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 <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 6719 matching lines...) Expand 10 before | Expand all | Expand 10 after
6730 host_impl_->SetExternalDrawConstraints(external_transform, 6730 host_impl_->SetExternalDrawConstraints(external_transform,
6731 external_viewport, 6731 external_viewport,
6732 external_clip, 6732 external_clip,
6733 resourceless_software_draw); 6733 resourceless_software_draw);
6734 DrawFrame(); 6734 DrawFrame();
6735 EXPECT_TRANSFORMATION_MATRIX_EQ( 6735 EXPECT_TRANSFORMATION_MATRIX_EQ(
6736 external_transform, layer->draw_properties().target_space_transform); 6736 external_transform, layer->draw_properties().target_space_transform);
6737 } 6737 }
6738 6738
6739 TEST_F(LayerTreeHostImplTest, ScrollAnimated) { 6739 TEST_F(LayerTreeHostImplTest, ScrollAnimated) {
6740 SetupScrollAndContentsLayers(gfx::Size(100, 100)); 6740 SetupScrollAndContentsLayers(gfx::Size(100, 150));
6741 host_impl_->SetViewportSize(gfx::Size(50, 50)); 6741 host_impl_->SetViewportSize(gfx::Size(50, 50));
6742 DrawFrame(); 6742 DrawFrame();
6743 6743
6744 base::TimeTicks start_time = 6744 base::TimeTicks start_time =
6745 base::TimeTicks() + base::TimeDelta::FromMilliseconds(100); 6745 base::TimeTicks() + base::TimeDelta::FromMilliseconds(100);
6746 6746
6747 EXPECT_EQ(InputHandler::ScrollStarted, 6747 EXPECT_EQ(InputHandler::ScrollStarted,
6748 host_impl_->ScrollAnimated(gfx::Point(), gfx::Vector2d(0, 50))); 6748 host_impl_->ScrollAnimated(gfx::Point(), gfx::Vector2d(0, 50)));
6749 6749
6750 LayerImpl* scrolling_layer = host_impl_->CurrentlyScrollingLayer(); 6750 LayerImpl* scrolling_layer = host_impl_->CurrentlyScrollingLayer();
6751 6751
6752 host_impl_->Animate(start_time); 6752 host_impl_->Animate(start_time);
6753 host_impl_->UpdateAnimationState(true); 6753 host_impl_->UpdateAnimationState(true);
6754 6754
6755 EXPECT_EQ(gfx::Vector2dF(), scrolling_layer->TotalScrollOffset()); 6755 EXPECT_EQ(gfx::Vector2dF(), scrolling_layer->TotalScrollOffset());
6756 6756
6757 host_impl_->Animate(start_time + base::TimeDelta::FromMilliseconds(50)); 6757 host_impl_->Animate(start_time + base::TimeDelta::FromMilliseconds(50));
6758 host_impl_->UpdateAnimationState(true); 6758 host_impl_->UpdateAnimationState(true);
6759 6759
6760 float y = scrolling_layer->TotalScrollOffset().y(); 6760 float y = scrolling_layer->TotalScrollOffset().y();
6761 EXPECT_TRUE(y > 1 && y < 49); 6761 EXPECT_TRUE(y > 1 && y < 49);
6762 6762
6763 // Update target.
6764 EXPECT_EQ(InputHandler::ScrollStarted,
6765 host_impl_->ScrollAnimated(gfx::Point(), gfx::Vector2d(0, 50)));
6766
6763 host_impl_->Animate(start_time + base::TimeDelta::FromMilliseconds(200)); 6767 host_impl_->Animate(start_time + base::TimeDelta::FromMilliseconds(200));
6764 host_impl_->UpdateAnimationState(true); 6768 host_impl_->UpdateAnimationState(true);
6765 6769
6766 EXPECT_EQ(gfx::Vector2dF(0, 50), scrolling_layer->TotalScrollOffset()); 6770 y = scrolling_layer->TotalScrollOffset().y();
6771 EXPECT_TRUE(y > 50 && y < 100);
6772 EXPECT_EQ(scrolling_layer, host_impl_->CurrentlyScrollingLayer());
6773
6774 host_impl_->Animate(start_time + base::TimeDelta::FromMilliseconds(250));
6775 host_impl_->UpdateAnimationState(true);
6776
6777 EXPECT_EQ(gfx::Vector2dF(0, 100), scrolling_layer->TotalScrollOffset());
6767 EXPECT_EQ(NULL, host_impl_->CurrentlyScrollingLayer()); 6778 EXPECT_EQ(NULL, host_impl_->CurrentlyScrollingLayer());
6768 } 6779 }
6769 6780
6770 } // namespace 6781 } // namespace
6771 } // namespace cc 6782 } // namespace cc
OLDNEW
« no previous file with comments | « cc/trees/layer_tree_host_impl.cc ('k') | ui/gfx/geometry/cubic_bezier.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698