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

Unified Diff: cc/trees/layer_tree_host_impl_unittest.cc

Issue 1009233002: CC Animations: Port Impl-only-scrolling to use compositor animation timelines. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@ui
Patch Set: Fix the nit. Created 5 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « cc/trees/layer_tree_host_impl.cc ('k') | cc/trees/layer_tree_host_unittest_animation_timelines.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: cc/trees/layer_tree_host_impl_unittest.cc
diff --git a/cc/trees/layer_tree_host_impl_unittest.cc b/cc/trees/layer_tree_host_impl_unittest.cc
index 0af96d323ecb3d9bdb91b23312db71cbf3881edd..9b49bf69a6403bce2e30b48ed929405a61c9c05a 100644
--- a/cc/trees/layer_tree_host_impl_unittest.cc
+++ b/cc/trees/layer_tree_host_impl_unittest.cc
@@ -432,6 +432,16 @@ class LayerTreeHostImplTest : public testing::Test,
base::TimeDelta requested_animation_delay_;
};
+// A test fixture for new animation timelines tests.
+class LayerTreeHostImplTimelinesTest : public LayerTreeHostImplTest {
+ public:
+ void SetUp() override {
+ LayerTreeSettings settings = DefaultSettings();
+ settings.use_compositor_animation_timelines = true;
+ CreateHostImpl(settings, CreateOutputSurface());
+ }
+};
+
TEST_F(LayerTreeHostImplTest, NotifyIfCanDrawChanged) {
bool always_draw = false;
CheckNotifyCalledIfCanDrawChanged(always_draw);
@@ -7646,6 +7656,49 @@ TEST_F(LayerTreeHostImplTest, ScrollAnimated) {
EXPECT_EQ(NULL, host_impl_->CurrentlyScrollingLayer());
}
+// Evolved from LayerTreeHostImplTest.ScrollAnimated.
+TEST_F(LayerTreeHostImplTimelinesTest, ScrollAnimated) {
+ SetupScrollAndContentsLayers(gfx::Size(100, 200));
+ DrawFrame();
+
+ base::TimeTicks start_time =
+ base::TimeTicks() + base::TimeDelta::FromMilliseconds(100);
+
+ EXPECT_EQ(InputHandler::SCROLL_STARTED,
+ host_impl_->ScrollAnimated(gfx::Point(), gfx::Vector2d(0, 50)));
+
+ LayerImpl* scrolling_layer = host_impl_->CurrentlyScrollingLayer();
+
+ host_impl_->Animate(start_time);
+ host_impl_->UpdateAnimationState(true);
+
+ EXPECT_EQ(gfx::ScrollOffset(), scrolling_layer->CurrentScrollOffset());
+
+ host_impl_->Animate(start_time + base::TimeDelta::FromMilliseconds(50));
+ host_impl_->UpdateAnimationState(true);
+
+ float y = scrolling_layer->CurrentScrollOffset().y();
+ EXPECT_TRUE(y > 1 && y < 49);
+
+ // Update target.
+ EXPECT_EQ(InputHandler::SCROLL_STARTED,
+ host_impl_->ScrollAnimated(gfx::Point(), gfx::Vector2d(0, 50)));
+
+ host_impl_->Animate(start_time + base::TimeDelta::FromMilliseconds(200));
+ host_impl_->UpdateAnimationState(true);
+
+ y = scrolling_layer->CurrentScrollOffset().y();
+ EXPECT_TRUE(y > 50 && y < 100);
+ EXPECT_EQ(scrolling_layer, host_impl_->CurrentlyScrollingLayer());
+
+ host_impl_->Animate(start_time + base::TimeDelta::FromMilliseconds(250));
+ host_impl_->UpdateAnimationState(true);
+
+ EXPECT_VECTOR_EQ(gfx::ScrollOffset(0, 100),
+ scrolling_layer->CurrentScrollOffset());
+ EXPECT_EQ(NULL, host_impl_->CurrentlyScrollingLayer());
+}
+
TEST_F(LayerTreeHostImplTest, InvalidLayerNotAddedToRasterQueue) {
host_impl_->CreatePendingTree();
« no previous file with comments | « cc/trees/layer_tree_host_impl.cc ('k') | cc/trees/layer_tree_host_unittest_animation_timelines.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698