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

Unified Diff: cc/trees/layer_tree_host_unittest.cc

Issue 15139007: Ensure LayerTreeHostImpl's current frame time is updated every frame (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Address review comments Created 7 years, 7 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
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 {

Powered by Google App Engine
This is Rietveld 408576698