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

Unified Diff: cc/trees/layer_tree_host_unittest_animation.cc

Issue 2796013003: cc: Push Animation Finished State and Use Finished State for IsCompleted (Closed)
Patch Set: clear events before update state in unittest Created 3 years, 8 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/animation/element_animations_unittest.cc ('k') | cc/trees/property_tree.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: cc/trees/layer_tree_host_unittest_animation.cc
diff --git a/cc/trees/layer_tree_host_unittest_animation.cc b/cc/trees/layer_tree_host_unittest_animation.cc
index f25dc93e40fc3d7dd4320a5730560f2e7a002a71..ac4c39688e1b72b8eaf59fe0e9ebb492992ab975 100644
--- a/cc/trees/layer_tree_host_unittest_animation.cc
+++ b/cc/trees/layer_tree_host_unittest_animation.cc
@@ -5,6 +5,7 @@
#include "cc/trees/layer_tree_host.h"
#include <stdint.h>
+#include <climits>
#include "cc/animation/animation_curve.h"
#include "cc/animation/animation_host.h"
@@ -1403,7 +1404,11 @@ class LayerTreeHostAnimationTestRemoveAnimation
player_child_->AttachElement(layer_->element_id());
}
- void BeginTest() override { PostSetNeedsCommitToMainThread(); }
+ void BeginTest() override {
+ animation_stopped_ = false;
+ last_frame_number_ = INT_MAX;
+ PostSetNeedsCommitToMainThread();
+ }
void DidCommit() override {
switch (layer_tree_host()->SourceFrameNumber()) {
@@ -1433,6 +1438,7 @@ class LayerTreeHostAnimationTestRemoveAnimation
}
void DrawLayersOnThread(LayerTreeHostImpl* host_impl) override {
+ GetImplTimelineAndPlayerByID(*host_impl);
LayerImpl* child = host_impl->active_tree()->LayerById(layer_->id());
switch (host_impl->active_tree()->source_frame_number()) {
case 0:
@@ -1443,18 +1449,37 @@ class LayerTreeHostAnimationTestRemoveAnimation
EXPECT_TRUE(child->screen_space_transform_is_animating());
break;
case 2: {
- // The animation is removed, the transform that was set afterward is
+ // The animation is stopped, the transform that was set afterward is
// applied.
gfx::Transform expected_transform;
expected_transform.Translate(10.f, 10.f);
EXPECT_TRANSFORMATION_MATRIX_EQ(expected_transform,
child->DrawTransform());
EXPECT_FALSE(child->screen_space_transform_is_animating());
- EndTest();
+ animation_stopped_ = true;
+ PostSetNeedsCommitToMainThread();
break;
}
- default:
- NOTREACHED();
+ }
+ }
+
+ void CommitCompleteOnThread(LayerTreeHostImpl* host_impl) override {
+ if (host_impl->sync_tree()->source_frame_number() >= last_frame_number_) {
+ // Check that eventually the animation is removed.
+ EXPECT_FALSE(player_child_impl_->has_any_animation());
+ EndTest();
+ }
+ }
+
+ void UpdateAnimationState(LayerTreeHostImpl* host_impl,
+ bool has_unfinished_animation) override {
+ // Non impl only animations are removed during commit. After the animation
+ // is fully stopped on compositor thread, make sure another commit happens.
+ if (animation_stopped_ && !has_unfinished_animation) {
+ last_frame_number_ =
+ std::min(last_frame_number_,
+ host_impl->active_tree()->source_frame_number() + 1);
+ PostSetNeedsCommitToMainThread();
}
}
@@ -1463,6 +1488,9 @@ class LayerTreeHostAnimationTestRemoveAnimation
private:
scoped_refptr<Layer> layer_;
FakeContentLayerClient client_;
+
+ int last_frame_number_;
+ bool animation_stopped_;
};
SINGLE_AND_MULTI_THREAD_TEST_F(LayerTreeHostAnimationTestRemoveAnimation);
« no previous file with comments | « cc/animation/element_animations_unittest.cc ('k') | cc/trees/property_tree.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698