| Index: ui/compositor/layer_unittest.cc
|
| diff --git a/ui/compositor/layer_unittest.cc b/ui/compositor/layer_unittest.cc
|
| index ac1a47b6ad24d52dff710463e1027fb4cd7bd5da..b5c473cffaba847d0211cdceb80c44000076be30 100644
|
| --- a/ui/compositor/layer_unittest.cc
|
| +++ b/ui/compositor/layer_unittest.cc
|
| @@ -95,8 +95,8 @@ class LayerWithRealCompositorTest : public testing::Test {
|
| 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();
|
| }
|
|
|
| @@ -126,7 +126,7 @@ class LayerWithRealCompositorTest : public testing::Test {
|
| void DrawTree(Layer* root) {
|
| GetCompositor()->SetRootLayer(root);
|
| GetCompositor()->ScheduleDraw();
|
| - WaitForDraw();
|
| + WaitForSwap();
|
| }
|
|
|
| bool ReadPixels(SkBitmap* bitmap) {
|
| @@ -142,11 +142,13 @@ class LayerWithRealCompositorTest : public testing::Test {
|
|
|
| GetCompositor()->root_layer()->RequestCopyOfOutput(request.Pass());
|
|
|
| - // 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();
|
| + // 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();
|
| WaitForDraw();
|
| }
|
|
|
| @@ -161,7 +163,11 @@ class LayerWithRealCompositorTest : public testing::Test {
|
| }
|
|
|
| void WaitForDraw() {
|
| - ui::DrawWaiterForTest::Wait(GetCompositor());
|
| + ui::DrawWaiterForTest::WaitForCompositingStarted(GetCompositor());
|
| + }
|
| +
|
| + void WaitForSwap() {
|
| + DrawWaiterForTest::WaitForCompositingEnded(GetCompositor());
|
| }
|
|
|
| void WaitForCommit() {
|
| @@ -450,7 +456,7 @@ class LayerWithDelegateTest : public testing::Test {
|
| }
|
|
|
| void WaitForDraw() {
|
| - DrawWaiterForTest::Wait(compositor());
|
| + DrawWaiterForTest::WaitForCompositingStarted(compositor());
|
| }
|
|
|
| void WaitForCommit() {
|
| @@ -945,25 +951,25 @@ TEST_F(LayerWithRealCompositorTest, CompositorObservers) {
|
| // Moving, but not resizing, a layer should alert the observers.
|
| observer.Reset();
|
| l2->SetBounds(gfx::Rect(0, 0, 350, 350));
|
| - WaitForDraw();
|
| + WaitForSwap();
|
| EXPECT_TRUE(observer.notified());
|
|
|
| // So should resizing a layer.
|
| observer.Reset();
|
| l2->SetBounds(gfx::Rect(0, 0, 400, 400));
|
| - WaitForDraw();
|
| + WaitForSwap();
|
| EXPECT_TRUE(observer.notified());
|
|
|
| // Opacity changes should alert the observers.
|
| observer.Reset();
|
| l2->SetOpacity(0.5f);
|
| - WaitForDraw();
|
| + WaitForSwap();
|
| EXPECT_TRUE(observer.notified());
|
|
|
| // So should setting the opacity back.
|
| observer.Reset();
|
| l2->SetOpacity(1.0f);
|
| - WaitForDraw();
|
| + WaitForSwap();
|
| EXPECT_TRUE(observer.notified());
|
|
|
| // Setting the transform of a layer should alert the observers.
|
| @@ -973,7 +979,7 @@ TEST_F(LayerWithRealCompositorTest, CompositorObservers) {
|
| transform.Rotate(90.0);
|
| transform.Translate(-200.0, -200.0);
|
| l2->SetTransform(transform);
|
| - WaitForDraw();
|
| + WaitForSwap();
|
| EXPECT_TRUE(observer.notified());
|
|
|
| // A change resulting in an aborted swap buffer should alert the observer
|
| @@ -981,7 +987,7 @@ TEST_F(LayerWithRealCompositorTest, CompositorObservers) {
|
| observer.Reset();
|
| l2->SetOpacity(0.1f);
|
| GetCompositor()->DidAbortSwapBuffers();
|
| - WaitForDraw();
|
| + WaitForSwap();
|
| EXPECT_TRUE(observer.notified());
|
| EXPECT_TRUE(observer.aborted());
|
|
|
| @@ -990,7 +996,7 @@ TEST_F(LayerWithRealCompositorTest, CompositorObservers) {
|
| // Opacity changes should no longer alert the removed observer.
|
| observer.Reset();
|
| l2->SetOpacity(0.5f);
|
| - WaitForDraw();
|
| + WaitForSwap();
|
|
|
| EXPECT_FALSE(observer.notified());
|
| }
|
|
|