| Index: cc/trees/layer_tree_host_unittest_context.cc
|
| diff --git a/cc/trees/layer_tree_host_unittest_context.cc b/cc/trees/layer_tree_host_unittest_context.cc
|
| index baf2b2ddbad5f0d43995504ebc24e2a96957b848..5c1bbac344d23a2836c070b004f8320c02862864 100644
|
| --- a/cc/trees/layer_tree_host_unittest_context.cc
|
| +++ b/cc/trees/layer_tree_host_unittest_context.cc
|
| @@ -67,9 +67,17 @@ class LayerTreeHostContextTest : public LayerTreeTest {
|
| }
|
|
|
| void LoseContext() {
|
| - context3d_->loseContextCHROMIUM(GL_GUILTY_CONTEXT_RESET_ARB,
|
| - GL_INNOCENT_CONTEXT_RESET_ARB);
|
| + // For sanity-checking tests, they should only call this when the
|
| + // context is not lost.
|
| + CHECK(context3d_);
|
| +
|
| + // Set the context3d_ member to null *before* calling lose context,
|
| + // as the single-threaded proxy may synchronously recreate the
|
| + // output surface, setting context3d_ back to not-NULL.
|
| + TestWebGraphicsContext3D* temp_context3d = context3d_;
|
| context3d_ = NULL;
|
| + temp_context3d->loseContextCHROMIUM(GL_GUILTY_CONTEXT_RESET_ARB,
|
| + GL_INNOCENT_CONTEXT_RESET_ARB);
|
| }
|
|
|
| virtual scoped_ptr<TestWebGraphicsContext3D> CreateContext3d() {
|
| @@ -497,10 +505,11 @@ class LayerTreeHostContextTestCreateOutputSurfaceFails
|
| expect_fallback_attempt_(expect_fallback_attempt),
|
| expect_to_give_up_(expect_to_give_up),
|
| did_attempt_fallback_(false),
|
| - times_initialized_(0) {}
|
| + times_initialized_(0) {
|
| + times_to_fail_create_ = times_to_fail_;
|
| + }
|
|
|
| virtual void BeginTest() OVERRIDE {
|
| - times_to_fail_create_ = times_to_fail_;
|
| PostSetNeedsCommitToMainThread();
|
| }
|
|
|
| @@ -1233,9 +1242,29 @@ class LayerTreeHostContextTestCompositeAndReadbackBeforeOutputSurfaceInit
|
| int times_output_surface_created_;
|
| };
|
|
|
| -SINGLE_AND_MULTI_THREAD_TEST_F(
|
| +// This test is only valid for the multi-threaded proxy. The single-threaded
|
| +// case synchronously creates the first output surface (tested just below)
|
| +// and so there is no way that a readback could happen during this time.
|
| +MULTI_THREAD_TEST_F(
|
| LayerTreeHostContextTestCompositeAndReadbackBeforeOutputSurfaceInit);
|
|
|
| +class LayerTreeHostContextTestSingleThreadSynchronouslyCreatesOutputSurface
|
| + : public LayerTreeHostContextTest {
|
| + public:
|
| + virtual void WillBeginTest() OVERRIDE {
|
| + // Output surface should be synchronously created, to avoid any potential
|
| + // readback issues before the first output surface is created.
|
| + ASSERT_TRUE(layer_tree_host()->output_surface_lost());
|
| + LayerTreeHostContextTest::WillBeginTest();
|
| + ASSERT_FALSE(layer_tree_host()->output_surface_lost());
|
| + }
|
| +
|
| + virtual void BeginTest() OVERRIDE { EndTest(); }
|
| + virtual void AfterTest() OVERRIDE {}
|
| +};
|
| +SINGLE_THREAD_TEST_F(
|
| + LayerTreeHostContextTestSingleThreadSynchronouslyCreatesOutputSurface);
|
| +
|
| // This test verifies that losing an output surface during a
|
| // simultaneous readback and forced redraw works and does not deadlock.
|
| class LayerTreeHostContextTestLoseOutputSurfaceDuringReadbackAndForcedDraw
|
| @@ -1481,12 +1510,6 @@ class ScrollbarLayerLostContext : public LayerTreeHostContextTest {
|
| EXPECT_EQ(2, scrollbar_layer_->update_count());
|
| EndTest();
|
| break;
|
| - case 3:
|
| - // Single thread proxy issues extra commits after context lost.
|
| - // http://crbug.com/287250
|
| - if (HasImplThread())
|
| - NOTREACHED();
|
| - break;
|
| default:
|
| NOTREACHED();
|
| }
|
| @@ -1530,12 +1553,10 @@ class UIResourceLostTest : public LayerTreeHostContextTest {
|
|
|
| void PostLoseContextToImplThread() {
|
| EXPECT_TRUE(layer_tree_host()->proxy()->IsMainThread());
|
| - base::SingleThreadTaskRunner* task_runner =
|
| - HasImplThread() ? ImplThreadTaskRunner()
|
| - : base::MessageLoopProxy::current();
|
| - task_runner->PostTask(FROM_HERE,
|
| - base::Bind(&LayerTreeHostContextTest::LoseContext,
|
| - base::Unretained(this)));
|
| + ImplThreadTaskRunner()->PostTask(
|
| + FROM_HERE,
|
| + base::Bind(&LayerTreeHostContextTest::LoseContext,
|
| + base::Unretained(this)));
|
| }
|
|
|
| protected:
|
| @@ -1590,13 +1611,8 @@ class UIResourceLostAfterCommit : public UIResourceLostTestSimple {
|
| EndTest();
|
| break;
|
| case 5:
|
| - // Single thread proxy issues extra commits after context lost.
|
| - // http://crbug.com/287250
|
| - if (HasImplThread())
|
| - NOTREACHED();
|
| - break;
|
| - case 6:
|
| NOTREACHED();
|
| + break;
|
| }
|
| }
|
|
|
| @@ -1684,13 +1700,8 @@ class UIResourceLostBeforeCommit : public UIResourceLostTestSimple {
|
| EndTest();
|
| break;
|
| case 6:
|
| - // Single thread proxy issues extra commits after context lost.
|
| - // http://crbug.com/287250
|
| - if (HasImplThread())
|
| - NOTREACHED();
|
| - break;
|
| - case 8:
|
| NOTREACHED();
|
| + break;
|
| }
|
| }
|
|
|
| @@ -1711,15 +1722,8 @@ class UIResourceLostBeforeCommit : public UIResourceLostTestSimple {
|
| // Sequence 2 (continued):
|
| // The previous resource should have been deleted.
|
| EXPECT_EQ(0u, impl->ResourceIdForUIResource(test_id0_));
|
| - if (HasImplThread()) {
|
| - // The second resource should have been created.
|
| - EXPECT_NE(0u, impl->ResourceIdForUIResource(test_id1_));
|
| - } else {
|
| - // The extra commit that happens at context lost in the single thread
|
| - // proxy changes the timing so that the resource has been destroyed.
|
| - // http://crbug.com/287250
|
| - EXPECT_EQ(0u, impl->ResourceIdForUIResource(test_id1_));
|
| - }
|
| + // The second resource should have been created.
|
| + EXPECT_NE(0u, impl->ResourceIdForUIResource(test_id1_));
|
| // The second resource called the resource callback once and since the
|
| // context is lost, a "resource lost" callback was also issued.
|
| EXPECT_EQ(2, ui_resource_->resource_create_count);
|
|
|