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 9d4650c200f1c708039f641803a99f6d2b1d90b4..1a60f0fa1350b853b683476d0fdcddc8d896696f 100644 |
--- a/cc/trees/layer_tree_host_unittest.cc |
+++ b/cc/trees/layer_tree_host_unittest.cc |
@@ -698,7 +698,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)); |
@@ -707,9 +708,16 @@ class LayerTreeHostTestFrameTimeUpdatesAfterActivationFails |
PostSetNeedsCommitToMainThread(); |
} |
+ 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; |
} |
@@ -719,33 +727,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) { |
+ 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_; |
}; |
@@ -838,7 +847,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()); |
@@ -1548,7 +1556,6 @@ class LayerTreeHostTestSurfaceNotAllocatedForLayersOutsideMemoryLimit |
surface1_render_pass_id)); |
EXPECT_FALSE(renderer->HaveCachedResourcesForRenderPassId( |
surface2_render_pass_id)); |
- |
EndTest(); |
break; |
} |
@@ -1560,9 +1567,9 @@ class LayerTreeHostTestSurfaceNotAllocatedForLayersOutsideMemoryLimit |
} |
virtual void AfterTest() OVERRIDE { |
- EXPECT_EQ(3u, root_layer_->update_count()); |
- EXPECT_EQ(3u, surface_layer1_->update_count()); |
- EXPECT_EQ(3u, surface_layer2_->update_count()); |
+ EXPECT_GE(root_layer_->update_count(), 2u); |
+ EXPECT_GE(surface_layer1_->update_count(), 2u); |
+ EXPECT_GE(surface_layer2_->update_count(), 2u); |
} |
private: |
@@ -2316,7 +2323,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; |
} |
@@ -2326,9 +2333,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 {} |
@@ -3049,6 +3056,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; |
} |