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

Unified Diff: cc/trees/layer_tree_host_unittest_context.cc

Issue 1287043002: cc: Setup API to release OutputSurface from LTHClient. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: update test. Created 5 years, 3 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 side-by-side diff with in-line comments
Download patch
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 7c766fe8bedc60376fafb543e8f51667e2c40682..b27fbcb36ebcad561d79af789fa2fd001445b2d1 100644
--- a/cc/trees/layer_tree_host_unittest_context.cc
+++ b/cc/trees/layer_tree_host_unittest_context.cc
@@ -382,6 +382,71 @@ class LayerTreeHostClientNotReadyDoesNotCreateOutputSurface
SINGLE_AND_MULTI_THREAD_TEST_F(
LayerTreeHostClientNotReadyDoesNotCreateOutputSurface);
+// This tests the OutputSurface release logic in the following sequence.
+// SetUp LTH and create and init OutputSurface
+// LTH::SetVisible(false);
+// LTH::ReleaseOutputSurface();
+// ...
+// LTH::SetVisible(true);
+// Create and init new OutputSurface
+class LayerTreeHostClientTakeAwayOutputSurface
+ : public LayerTreeHostContextTest {
+ public:
+ LayerTreeHostClientTakeAwayOutputSurface()
+ : LayerTreeHostContextTest(), setos_counter_(0) {}
+
+ void BeginTest() override { PostSetNeedsCommitToMainThread(); }
+
+ void RequestNewOutputSurface() override {
+ if (layer_tree_host()->visible())
+ CreateAndSetOutputSurface();
+ }
+
+ void CreateAndSetOutputSurface() {
+ scoped_ptr<OutputSurface> surface =
+ LayerTreeHostContextTest::CreateOutputSurface();
+ CHECK(surface);
+ setos_counter_++;
+ layer_tree_host()->SetOutputSurface(surface.Pass());
+ }
+
+ void HideAndReleaseOutputSurface() {
+ EXPECT_TRUE(layer_tree_host()->proxy()->IsMainThread());
+ layer_tree_host()->SetVisible(false);
+ scoped_ptr<OutputSurface> surface =
+ layer_tree_host()->ReleaseOutputSurface();
+ CHECK(surface);
+ surface->context_provider()->DetachFromThread();
+ MainThreadTaskRunner()->PostTask(
+ FROM_HERE,
+ base::Bind(&LayerTreeHostClientTakeAwayOutputSurface::MakeVisible,
+ base::Unretained(this)));
+ }
+
+ void DidInitializeOutputSurface() override {
+ EXPECT_TRUE(layer_tree_host()->visible());
+ if (setos_counter_ == 1) {
+ MainThreadTaskRunner()->PostTask(
+ FROM_HERE, base::Bind(&LayerTreeHostClientTakeAwayOutputSurface::
+ HideAndReleaseOutputSurface,
+ base::Unretained(this)));
+ } else {
+ EndTest();
+ }
+ }
+
+ void MakeVisible() {
+ EXPECT_TRUE(layer_tree_host()->proxy()->IsMainThread());
+ layer_tree_host()->SetVisible(true);
+ }
+
+ void AfterTest() override {}
+
+ int setos_counter_;
+};
+
+SINGLE_AND_MULTI_THREAD_TEST_F(LayerTreeHostClientTakeAwayOutputSurface);
+
class MultipleCompositeDoesNotCreateOutputSurface
: public LayerTreeHostContextTest {
public:

Powered by Google App Engine
This is Rietveld 408576698