Index: cc/trees/layer_tree_host_unittest.cc |
diff --git a/cc/trees/layer_tree_host_unittest.cc b/cc/trees/layer_tree_host_unittest.cc |
index 3426d41fe446a15f5982801e99a5df4d09896e65..55ebd95c576a0662f3f8a3fd438dd7dca5d56905 100644 |
--- a/cc/trees/layer_tree_host_unittest.cc |
+++ b/cc/trees/layer_tree_host_unittest.cc |
@@ -626,6 +626,86 @@ class LayerTreeHostTestCommit : public LayerTreeHostTest { |
MULTI_THREAD_TEST_F(LayerTreeHostTestCommit); |
+// This test verifies that LayerTreeHostImpl's current frame time gets |
+// updated in consecutive frames when it doesn't draw due to tree |
+// activation failure. |
+class LayerTreeHostTestFrameTimeUpdatesAfterActivationFails |
+ : public LayerTreeHostTest { |
+ public: |
+ LayerTreeHostTestFrameTimeUpdatesAfterActivationFails() : frame_(0) {} |
+ |
+ virtual void BeginTest() OVERRIDE { |
+ layer_tree_host()->SetViewportSize(gfx::Size(20, 20)); |
+ layer_tree_host()->set_background_color(SK_ColorGRAY); |
+ |
+ PostSetNeedsCommitToMainThread(); |
+ } |
+ |
+ virtual void DrawLayersOnThread(LayerTreeHostImpl* impl) OVERRIDE { |
+ if (frame_ >= 1) { |
+ EXPECT_NE(first_frame_time_, impl->CurrentFrameTimeTicks()); |
+ EndTest(); |
+ return; |
+ } |
+ |
+ EXPECT_FALSE(impl->settings().impl_side_painting); |
+ EndTest(); |
+ } |
+ |
+ virtual bool CanActivatePendingTree(LayerTreeHostImpl* impl) OVERRIDE { |
+ frame_++; |
+ if (frame_ == 1) { |
+ first_frame_time_ = impl->CurrentFrameTimeTicks(); |
+ return false; |
+ } |
+ |
+ return true; |
+ } |
+ |
+ virtual void AfterTest() OVERRIDE {} |
+ |
+ private: |
+ int frame_; |
+ base::TimeTicks first_frame_time_; |
+}; |
+ |
+SINGLE_AND_MULTI_THREAD_TEST_F( |
+ LayerTreeHostTestFrameTimeUpdatesAfterActivationFails); |
+ |
+// This test verifies that LayerTreeHostImpl's current frame time gets |
+// updated in consecutive frames when it draws in each frame. |
+class LayerTreeHostTestFrameTimeUpdatesAfterDraw : public LayerTreeHostTest { |
+ public: |
+ LayerTreeHostTestFrameTimeUpdatesAfterDraw() : frame_(0) {} |
+ |
+ virtual void BeginTest() OVERRIDE { |
+ layer_tree_host()->SetViewportSize(gfx::Size(20, 20)); |
+ layer_tree_host()->set_background_color(SK_ColorGRAY); |
+ |
+ PostSetNeedsCommitToMainThread(); |
+ } |
+ |
+ virtual void DrawLayersOnThread(LayerTreeHostImpl* impl) OVERRIDE { |
+ frame_++; |
+ if (frame_ == 1) { |
+ first_frame_time_ = impl->CurrentFrameTimeTicks(); |
+ impl->SetNeedsRedraw(); |
danakj
2013/05/16 17:42:38
Can you add a CommitCompleteOnThread override and
ajuma
2013/05/16 19:50:01
Done.
|
+ return; |
+ } |
+ |
+ EXPECT_NE(first_frame_time_, impl->CurrentFrameTimeTicks()); |
+ EndTest(); |
+ } |
+ |
+ virtual void AfterTest() OVERRIDE {} |
+ |
+ private: |
+ int frame_; |
+ base::TimeTicks first_frame_time_; |
+}; |
+ |
+SINGLE_AND_MULTI_THREAD_TEST_F(LayerTreeHostTestFrameTimeUpdatesAfterDraw); |
+ |
// Verifies that StartPageScaleAnimation events propagate correctly |
// from LayerTreeHost to LayerTreeHostImpl in the MT compositor. |
class LayerTreeHostTestStartPageScaleAnimation : public LayerTreeHostTest { |