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

Unified Diff: cc/trees/layer_tree_host_impl_unittest.cc

Issue 615953005: Move page scale animation from LayerTreeHostImpl to LayerTreeImpl (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Added CC_EXPORT to PageScaleAnimation Created 6 years, 2 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_impl.h » ('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 56b8c221ded6802cd403fa5c9be2af92e161aa84..cb52be725b97496e8d883193e5700cdd3be047f6 100644
--- a/cc/trees/layer_tree_host_impl_unittest.cc
+++ b/cc/trees/layer_tree_host_impl_unittest.cc
@@ -13,6 +13,7 @@
#include "cc/animation/scrollbar_animation_controller_thinning.h"
#include "cc/base/latency_info_swap_promise.h"
#include "cc/base/math_util.h"
+#include "cc/input/page_scale_animation.h"
#include "cc/input/top_controls_manager.h"
#include "cc/layers/append_quads_data.h"
#include "cc/layers/delegated_renderer_layer_impl.h"
@@ -1154,7 +1155,12 @@ TEST_F(LayerTreeHostImplTest, PageScaleAnimation) {
did_request_redraw_ = false;
did_request_animate_ = false;
- host_impl_->StartPageScaleAnimation(gfx::Vector2d(), false, 2.f, duration);
+ host_impl_->active_tree()->SetPageScaleAnimation(
+ gfx::Vector2d(),
+ false,
+ 2.f,
+ duration);
+ host_impl_->ActivateSyncTree();
EXPECT_FALSE(did_request_redraw_);
EXPECT_TRUE(did_request_animate_);
@@ -1192,8 +1198,9 @@ TEST_F(LayerTreeHostImplTest, PageScaleAnimation) {
did_request_redraw_ = false;
did_request_animate_ = false;
- host_impl_->StartPageScaleAnimation(
+ host_impl_->active_tree()->SetPageScaleAnimation(
gfx::Vector2d(25, 25), true, min_page_scale, duration);
+ host_impl_->ActivateSyncTree();
EXPECT_FALSE(did_request_redraw_);
EXPECT_TRUE(did_request_animate_);
@@ -1242,7 +1249,12 @@ TEST_F(LayerTreeHostImplTest, PageScaleAnimationNoOp) {
max_page_scale);
scroll_layer->SetScrollOffset(gfx::ScrollOffset(50, 50));
- host_impl_->StartPageScaleAnimation(gfx::Vector2d(), true, 1.f, duration);
+ host_impl_->active_tree()->SetPageScaleAnimation(
+ gfx::Vector2d(),
+ true,
+ 1.f,
+ duration);
+ host_impl_->ActivateSyncTree();
host_impl_->Animate(start_time);
host_impl_->Animate(halfway_through_animation);
EXPECT_TRUE(did_request_redraw_);
@@ -1256,6 +1268,91 @@ TEST_F(LayerTreeHostImplTest, PageScaleAnimationNoOp) {
}
}
+TEST_F(LayerTreeHostImplTest, PageScaleAnimationTransferedOnSyncTreeActivate) {
+ host_impl_->CreatePendingTree();
+ CreateScrollAndContentsLayers(
+ host_impl_->pending_tree(),
+ gfx::Size(100, 100));
+ host_impl_->ActivateSyncTree();
+ DrawFrame();
+
+ LayerImpl* scroll_layer = host_impl_->InnerViewportScrollLayer();
+ DCHECK(scroll_layer);
+
+ float min_page_scale = 0.5f;
+ float max_page_scale = 4.f;
+ host_impl_->sync_tree()->SetPageScaleFactorAndLimits(1.f,
+ min_page_scale,
+ max_page_scale);
+ host_impl_->ActivateSyncTree();
+
+ base::TimeTicks start_time = base::TimeTicks() +
+ base::TimeDelta::FromSeconds(1);
+ base::TimeDelta duration = base::TimeDelta::FromMilliseconds(100);
+ base::TimeTicks halfway_through_animation = start_time + duration / 2;
+ base::TimeTicks end_time = start_time + duration;
+ float target_scale = 2.f;
+
+ scroll_layer->SetScrollOffset(gfx::ScrollOffset(50, 50));
+
+ // Make sure TakePageScaleAnimation works properly.
+ host_impl_->sync_tree()->SetPageScaleAnimation(
+ gfx::Vector2d(),
+ false,
+ target_scale,
+ duration);
+ scoped_ptr<PageScaleAnimation> psa =
+ host_impl_->sync_tree()->TakePageScaleAnimation();
+ EXPECT_EQ(target_scale, psa->target_page_scale_factor());
+ EXPECT_EQ(duration, psa->duration());
+ EXPECT_EQ(nullptr, host_impl_->sync_tree()->TakePageScaleAnimation());
+
+ // Recreate the PSA. Nothing should happen here since the tree containing the
+ // PSA hasn't been activated yet.
+ did_request_redraw_ = false;
+ did_request_animate_ = false;
+ host_impl_->sync_tree()->SetPageScaleAnimation(
+ gfx::Vector2d(),
+ false,
+ target_scale,
+ duration);
+ host_impl_->Animate(halfway_through_animation);
+ EXPECT_FALSE(did_request_animate_);
+ EXPECT_FALSE(did_request_redraw_);
+
+ // Activate the sync tree. This should cause the animation to become enabled.
+ // It should also clear the pointer on the sync tree.
+ host_impl_->ActivateSyncTree();
+ EXPECT_EQ(nullptr, host_impl_->sync_tree()->TakePageScaleAnimation().get());
+ EXPECT_FALSE(did_request_redraw_);
+ EXPECT_TRUE(did_request_animate_);
+
+ // From here on, make sure the animation runs as normal.
+ did_request_redraw_ = false;
+ did_request_animate_ = false;
+ host_impl_->Animate(start_time);
+ EXPECT_TRUE(did_request_redraw_);
+ EXPECT_TRUE(did_request_animate_);
+
+ did_request_redraw_ = false;
+ did_request_animate_ = false;
+ host_impl_->Animate(halfway_through_animation);
+ EXPECT_TRUE(did_request_redraw_);
+ EXPECT_TRUE(did_request_animate_);
+
+ did_request_redraw_ = false;
+ did_request_animate_ = false;
+ did_request_commit_ = false;
+ host_impl_->Animate(end_time);
+ EXPECT_TRUE(did_request_commit_);
+ EXPECT_FALSE(did_request_animate_);
+
+ scoped_ptr<ScrollAndScaleSet> scroll_info =
+ host_impl_->ProcessScrollDeltas();
+ EXPECT_EQ(scroll_info->page_scale_delta, target_scale);
+ ExpectContains(*scroll_info, scroll_layer->id(), gfx::Vector2d(-50, -50));
+}
+
class LayerTreeHostImplOverridePhysicalTime : public LayerTreeHostImpl {
public:
LayerTreeHostImplOverridePhysicalTime(
« no previous file with comments | « cc/trees/layer_tree_host_impl.cc ('k') | cc/trees/layer_tree_impl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698