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

Side by Side Diff: cc/trees/layer_tree_host_unittest_context.cc

Issue 321193002: cc: Test losing the output surface during deferred commits. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 6 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « cc/test/layer_tree_test.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2012 The Chromium Authors. All rights reserved. 1 // Copyright 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "cc/trees/layer_tree_host.h" 5 #include "cc/trees/layer_tree_host.h"
6 6
7 #include "base/basictypes.h" 7 #include "base/basictypes.h"
8 #include "cc/layers/content_layer.h" 8 #include "cc/layers/content_layer.h"
9 #include "cc/layers/delegated_frame_provider.h" 9 #include "cc/layers/delegated_frame_provider.h"
10 #include "cc/layers/delegated_frame_resource_collection.h" 10 #include "cc/layers/delegated_frame_resource_collection.h"
(...skipping 1455 matching lines...) Expand 10 before | Expand all | Expand 10 after
1466 1466
1467 virtual void AfterTest() OVERRIDE {} 1467 virtual void AfterTest() OVERRIDE {}
1468 1468
1469 protected: 1469 protected:
1470 FakeContentLayerClient client_; 1470 FakeContentLayerClient client_;
1471 scoped_refptr<FakeContentLayer> layer_; 1471 scoped_refptr<FakeContentLayer> layer_;
1472 }; 1472 };
1473 1473
1474 SINGLE_AND_MULTI_THREAD_TEST_F(LayerTreeHostContextTestSurfaceCreateCallback); 1474 SINGLE_AND_MULTI_THREAD_TEST_F(LayerTreeHostContextTestSurfaceCreateCallback);
1475 1475
1476 class LayerTreeHostContextTestLoseAfterSendingBeginMainFrame
1477 : public LayerTreeHostContextTest {
1478 protected:
1479 virtual void BeginTest() OVERRIDE {
1480 deferred_ = false;
1481 PostSetNeedsCommitToMainThread();
1482 }
1483
1484 virtual void ScheduledActionWillSendBeginMainFrame() OVERRIDE {
1485 if (deferred_)
1486 return;
1487 deferred_ = true;
1488
1489 // Defer commits before the BeginFrame arrives, causing it to be delayed.
1490 MainThreadTaskRunner()->PostTask(
1491 FROM_HERE,
1492 base::Bind(&LayerTreeHostContextTestLoseAfterSendingBeginMainFrame::
1493 DeferCommitsOnMainThread,
1494 base::Unretained(this),
1495 true));
1496 // Meanwhile, lose the context while we are in defer commits.
1497 ImplThreadTaskRunner()->PostTask(
1498 FROM_HERE,
1499 base::Bind(&LayerTreeHostContextTestLoseAfterSendingBeginMainFrame::
1500 LoseContextOnImplThread,
1501 base::Unretained(this)));
1502 }
1503
1504 void LoseContextOnImplThread() {
1505 LoseContext();
1506
1507 // After losing the context, stop deferring commits.
1508 MainThreadTaskRunner()->PostTask(
enne (OOO) 2014/06/10 18:43:32 This seems racy. Couldn't DeferCommitsOnMainThrea
danakj 2014/06/10 18:46:24 I think not because after ScheduledActionWillSendB
enne (OOO) 2014/06/10 18:59:43 Oh, right. ScheduledActionWillSendBeginMainFrame
1509 FROM_HERE,
1510 base::Bind(&LayerTreeHostContextTestLoseAfterSendingBeginMainFrame::
1511 DeferCommitsOnMainThread,
1512 base::Unretained(this),
1513 false));
1514 }
1515
1516 void DeferCommitsOnMainThread(bool defer_commits) {
1517 layer_tree_host()->SetDeferCommits(defer_commits);
1518 }
1519
1520 virtual void WillBeginMainFrame() OVERRIDE {
1521 // Don't begin a frame with a lost surface.
1522 EXPECT_FALSE(layer_tree_host()->output_surface_lost());
1523 }
1524
1525 virtual void DidCommitAndDrawFrame() OVERRIDE { EndTest(); }
1526
1527 virtual void AfterTest() OVERRIDE {}
1528
1529 bool deferred_;
1530 };
1531
1532 // TODO(danakj): We don't use scheduler with SingleThreadProxy yet.
1533 MULTI_THREAD_TEST_F(LayerTreeHostContextTestLoseAfterSendingBeginMainFrame);
1534
1476 } // namespace 1535 } // namespace
1477 } // namespace cc 1536 } // namespace cc
OLDNEW
« no previous file with comments | « cc/test/layer_tree_test.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698