+// Ensure that animation time is correctly updated when animations are frozen
+// because of checkerboarding.
+class LayerTreeHostAnimationTestFrozenAnimationTickTime
+ : public LayerTreeHostAnimationTest {
+ public:
+ LayerTreeHostAnimationTestFrozenAnimationTickTime()
+ : started_animating_(false), num_commits_(0), num_draw_attempts_(2) {}
+
+ virtual void InitializeSettings(LayerTreeSettings* settings) OVERRIDE {
+ // Make sure that drawing many times doesn't cause a checkerboarded
+ // animation to start so we avoid flake in this test.
+ settings->timeout_and_draw_when_animation_checkerboards = false;
+ }
+
+ virtual void BeginTest() OVERRIDE {
+ PostAddAnimationToMainThread(layer_tree_host()->root_layer());
+ }
+
+ virtual void Animate(base::TimeTicks monotonic_time) OVERRIDE {
+ last_main_thread_tick_time_ = monotonic_time;
+ }
+
+ virtual void AnimateLayers(LayerTreeHostImpl* host_impl,
+ base::TimeTicks monotonic_time) OVERRIDE {
+ if (TestEnded())
+ return;
+ if (!started_animating_) {
+ started_animating_ = true;
+ expected_impl_tick_time_ = monotonic_time;
+ } else {
+ EXPECT_EQ(expected_impl_tick_time_, monotonic_time);
+ if (num_commits_ > 2)
+ EndTest();
+ }
+ }
+
+ virtual DrawSwapReadbackResult::DrawResult PrepareToDrawOnThread(
+ LayerTreeHostImpl* host_impl,
+ LayerTreeHostImpl::FrameData* frame,
+ DrawSwapReadbackResult::DrawResult draw_result) OVERRIDE {
+ if (TestEnded())
+ return draw_result;
+ num_draw_attempts_++;
+ if (num_draw_attempts_ > 2) {
+ num_draw_attempts_ = 0;
+ PostSetNeedsCommitToMainThread();
+ }
+ return DrawSwapReadbackResult::DRAW_ABORTED_CHECKERBOARD_ANIMATIONS;
+ }
+
+ virtual void BeginCommitOnThread(LayerTreeHostImpl* host_impl) OVERRIDE {
+ if (!started_animating_)
+ return;
+ expected_impl_tick_time_ =
+ std::max(expected_impl_tick_time_, last_main_thread_tick_time_);
+ num_commits_++;
+ }
+
+ virtual void AfterTest() OVERRIDE {}
+
+ private:
+ bool started_animating_;
+ int num_commits_;
+ int num_draw_attempts_;
+ base::TimeTicks last_main_thread_tick_time_;
+ base::TimeTicks expected_impl_tick_time_;
+};
+
+// Only the non-impl-paint multi-threaded compositor freezes animations.
+MULTI_THREAD_NOIMPL_TEST_F(LayerTreeHostAnimationTestFrozenAnimationTickTime);
+