Index: trunk/src/ui/compositor/layer_unittest.cc |
=================================================================== |
--- trunk/src/ui/compositor/layer_unittest.cc (revision 280520) |
+++ trunk/src/ui/compositor/layer_unittest.cc (working copy) |
@@ -94,8 +94,8 @@ |
InitializeContextFactoryForTests(enable_pixel_output); |
const gfx::Rect host_bounds(10, 10, 500, 500); |
- compositor_host_.reset( |
- TestCompositorHost::Create(host_bounds, context_factory)); |
+ compositor_host_.reset(TestCompositorHost::Create( |
+ host_bounds, context_factory)); |
compositor_host_->Show(); |
} |
@@ -125,7 +125,7 @@ |
void DrawTree(Layer* root) { |
GetCompositor()->SetRootLayer(root); |
GetCompositor()->ScheduleDraw(); |
- WaitForSwap(); |
+ WaitForDraw(); |
} |
bool ReadPixels(SkBitmap* bitmap) { |
@@ -141,13 +141,11 @@ |
GetCompositor()->root_layer()->RequestCopyOfOutput(request.Pass()); |
- // Wait for copy response. The copy output request will get committed |
- // before the first draw, but may not be part of the first draw's frame. |
- // The second draw will perform the async copy request, post the callback. |
- // The second loop finishes before the callback is run, so a third |
- // loop is needed. |
- for (int i = 0; i < 3; i++) { |
- GetCompositor()->ScheduleFullRedraw(); |
+ // Wait for copy response. This needs to wait as the compositor could |
+ // be in the middle of a draw right now, and the commit with the |
+ // copy output request may not be done on the first draw. |
+ for (int i = 0; i < 2; i++) { |
+ GetCompositor()->ScheduleDraw(); |
WaitForDraw(); |
} |
@@ -162,13 +160,9 @@ |
} |
void WaitForDraw() { |
- ui::DrawWaiterForTest::WaitForCompositingStarted(GetCompositor()); |
+ ui::DrawWaiterForTest::Wait(GetCompositor()); |
} |
- void WaitForSwap() { |
- DrawWaiterForTest::WaitForCompositingEnded(GetCompositor()); |
- } |
- |
void WaitForCommit() { |
ui::DrawWaiterForTest::WaitForCommit(GetCompositor()); |
} |
@@ -455,7 +449,7 @@ |
} |
void WaitForDraw() { |
- DrawWaiterForTest::WaitForCompositingStarted(compositor()); |
+ DrawWaiterForTest::Wait(compositor()); |
} |
void WaitForCommit() { |
@@ -950,25 +944,25 @@ |
// Moving, but not resizing, a layer should alert the observers. |
observer.Reset(); |
l2->SetBounds(gfx::Rect(0, 0, 350, 350)); |
- WaitForSwap(); |
+ WaitForDraw(); |
EXPECT_TRUE(observer.notified()); |
// So should resizing a layer. |
observer.Reset(); |
l2->SetBounds(gfx::Rect(0, 0, 400, 400)); |
- WaitForSwap(); |
+ WaitForDraw(); |
EXPECT_TRUE(observer.notified()); |
// Opacity changes should alert the observers. |
observer.Reset(); |
l2->SetOpacity(0.5f); |
- WaitForSwap(); |
+ WaitForDraw(); |
EXPECT_TRUE(observer.notified()); |
// So should setting the opacity back. |
observer.Reset(); |
l2->SetOpacity(1.0f); |
- WaitForSwap(); |
+ WaitForDraw(); |
EXPECT_TRUE(observer.notified()); |
// Setting the transform of a layer should alert the observers. |
@@ -978,7 +972,7 @@ |
transform.Rotate(90.0); |
transform.Translate(-200.0, -200.0); |
l2->SetTransform(transform); |
- WaitForSwap(); |
+ WaitForDraw(); |
EXPECT_TRUE(observer.notified()); |
// A change resulting in an aborted swap buffer should alert the observer |
@@ -986,7 +980,7 @@ |
observer.Reset(); |
l2->SetOpacity(0.1f); |
GetCompositor()->DidAbortSwapBuffers(); |
- WaitForSwap(); |
+ WaitForDraw(); |
EXPECT_TRUE(observer.notified()); |
EXPECT_TRUE(observer.aborted()); |
@@ -995,7 +989,7 @@ |
// Opacity changes should no longer alert the removed observer. |
observer.Reset(); |
l2->SetOpacity(0.5f); |
- WaitForSwap(); |
+ WaitForDraw(); |
EXPECT_FALSE(observer.notified()); |
} |