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

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: 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
« no previous file with comments | « cc/trees/layer_tree_host_impl.cc ('k') | cc/trees/layer_tree_host_unittest_scroll.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.cc
diff --git a/cc/trees/layer_tree_host_unittest.cc b/cc/trees/layer_tree_host_unittest.cc
index 3426d41fe446a15f5982801e99a5df4d09896e65..ece753c5e9474ef8f78e8ad2402e6f1debfb8f88 100644
--- a/cc/trees/layer_tree_host_unittest.cc
+++ b/cc/trees/layer_tree_host_unittest.cc
@@ -626,6 +626,107 @@ 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();
+
+ // Since base::TimeTicks::Now() uses a low-resolution clock on
+ // Windows, we need to make sure that the clock has incremented past
+ // first_frame_time_.
+ while (first_frame_time_ == base::TimeTicks::Now());
danakj 2013/05/17 13:39:36 nit: use {} instead of ; to end the line
ajuma 2013/05/17 13:46:50 Done.
+
+ 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();
+
+ // Since base::TimeTicks::Now() uses a low-resolution clock on
+ // Windows, we need to make sure that the clock has incremented past
+ // first_frame_time_.
+ while (first_frame_time_ == base::TimeTicks::Now());
ajuma 2013/05/17 13:36:45 This test (and the next one) was flaking on Window
danakj 2013/05/17 13:39:36 and here
ajuma 2013/05/17 13:46:50 Done.
+
+ return;
+ }
+
+ EXPECT_NE(first_frame_time_, impl->CurrentFrameTimeTicks());
+ EndTest();
+ }
+
+ virtual void CommitCompleteOnThread(LayerTreeHostImpl* host_impl) OVERRIDE {
+ // Ensure there isn't a commit between the two draws, to ensure that a
+ // commit isn't required for updating the current frame time. We can
+ // only check for this in the multi-threaded case, since in the single-
+ // threaded case there will always be a commit between consecutive draws.
+ if (ImplThread())
+ EXPECT_EQ(0, frame_);
+ }
+
+ 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 {
« no previous file with comments | « cc/trees/layer_tree_host_impl.cc ('k') | cc/trees/layer_tree_host_unittest_scroll.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698