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

Unified Diff: cc/trees/layer_tree_host_unittest.cc

Issue 16871016: cc: Use BeginFrameArgs (Closed) Base URL: http://git.chromium.org/chromium/src.git@bfargs2
Patch Set: Fixed all existing tests! New tests pending... Created 7 years, 5 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 b341f92db3580878fadd2d04ff9e46e3110fbdb7..dae33e69b9551af6da3b400f68786747f198d35c 100644
--- a/cc/trees/layer_tree_host_unittest.cc
+++ b/cc/trees/layer_tree_host_unittest.cc
@@ -697,7 +697,8 @@ MULTI_THREAD_TEST_F(LayerTreeHostTestCommit);
class LayerTreeHostTestFrameTimeUpdatesAfterActivationFails
: public LayerTreeHostTest {
public:
- LayerTreeHostTestFrameTimeUpdatesAfterActivationFails() : frame_(0) {}
+ LayerTreeHostTestFrameTimeUpdatesAfterActivationFails()
+ : frame_count_with_pending_tree_(0) {}
virtual void BeginTest() OVERRIDE {
layer_tree_host()->SetViewportSize(gfx::Size(20, 20));
@@ -706,9 +707,16 @@ class LayerTreeHostTestFrameTimeUpdatesAfterActivationFails
PostSetNeedsCommitToMainThread();
}
+ virtual void WillBeginFrameOnThread(LayerTreeHostImpl* host_impl,
+ const BeginFrameArgs &args) OVERRIDE {
+ if (host_impl->pending_tree())
+ frame_count_with_pending_tree_++;
+ }
+
virtual void DrawLayersOnThread(LayerTreeHostImpl* impl) OVERRIDE {
- if (frame_ >= 1) {
- EXPECT_NE(first_frame_time_, impl->CurrentFrameTimeTicks());
+ if (frame_count_with_pending_tree_ > 1) {
+ EXPECT_NE(first_frame_time_.ToInternalValue(),
+ impl->CurrentFrameTimeTicks().ToInternalValue());
EndTest();
return;
}
@@ -718,33 +726,34 @@ class LayerTreeHostTestFrameTimeUpdatesAfterActivationFails
}
virtual bool CanActivatePendingTree(LayerTreeHostImpl* impl) OVERRIDE {
- if (frame_ >= 1)
- return true;
-
- return false;
+ return frame_count_with_pending_tree_ > 1;
}
virtual bool CanActivatePendingTreeIfNeeded(LayerTreeHostImpl* impl)
OVERRIDE {
- frame_++;
- if (frame_ == 1) {
+ if (frame_count_with_pending_tree_ > 1)
+ return true;
+
+ if (first_frame_time_.is_null()) {
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()) {}
-
- return false;
}
+ return false;
+ }
- return true;
+ virtual void DidActivateTreeOnThread(LayerTreeHostImpl *impl) OVERRIDE {
+ if (impl->settings().impl_side_painting)
+ EXPECT_NE(frame_count_with_pending_tree_, 1);
}
virtual void AfterTest() OVERRIDE {}
private:
- int frame_;
+ int frame_count_with_pending_tree_;
base::TimeTicks first_frame_time_;
};
@@ -837,7 +846,6 @@ class LayerTreeHostTestStartPageScaleAnimation : public LayerTreeHostTest {
break;
case 1:
EXPECT_EQ(1.f, impl->active_tree()->page_scale_factor());
- PostSetNeedsRedrawToMainThread();
break;
case 2:
EXPECT_EQ(1.25f, impl->active_tree()->page_scale_factor());
@@ -1545,7 +1553,6 @@ class LayerTreeHostTestSurfaceNotAllocatedForLayersOutsideMemoryLimit
surface1_render_pass_id));
EXPECT_FALSE(renderer->HaveCachedResourcesForRenderPassId(
surface2_render_pass_id));
-
EndTest();
break;
}
@@ -2243,7 +2250,7 @@ class LayerTreeHostTestBeginFrameNotificationShutdownWhileEnabled
: public LayerTreeHostTest {
public:
virtual void InitializeSettings(LayerTreeSettings* settings) OVERRIDE {
- settings->begin_frame_scheduling_enabled = true;
+ settings->begin_frame_scheduling_enabled = false;
settings->using_synchronous_renderer_compositor = true;
}
@@ -2253,9 +2260,9 @@ class LayerTreeHostTestBeginFrameNotificationShutdownWhileEnabled
// The BeginFrame notification is turned off now but will get enabled
// once we return. End test while it's enabled.
ImplThreadTaskRunner()->PostTask(
- FROM_HERE,
- base::Bind(&LayerTreeHostTestBeginFrameNotification::EndTest,
- base::Unretained(this)));
+ FROM_HERE, base::Bind(
+ &LayerTreeHostTestBeginFrameNotificationShutdownWhileEnabled::EndTest,
+ base::Unretained(this)));
}
virtual void AfterTest() OVERRIDE {}
@@ -2976,6 +2983,10 @@ class LayerTreeHostTestNumFramesPending : public LayerTreeHostTest {
// Round 4 done.
EXPECT_EQ(2, frame_);
layer_tree_host()->SetNeedsCommit();
+ // We cant SetNeedsRedraw immediately because it will race the commit.
+ break;
+ case 5:
+ EXPECT_EQ(2, frame_);
layer_tree_host()->SetNeedsRedraw();
break;
}

Powered by Google App Engine
This is Rietveld 408576698