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

Unified Diff: cc/layers/texture_layer_unittest.cc

Issue 2609253003: Remove ForceReclaimResources (Closed)
Patch Set: Make test cases / phases the same Created 3 years, 11 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
« no previous file with comments | « no previous file | cc/output/compositor_frame_sink.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: cc/layers/texture_layer_unittest.cc
diff --git a/cc/layers/texture_layer_unittest.cc b/cc/layers/texture_layer_unittest.cc
index 7d10bf7ee4ae7739693a0d58c5afe75ac8d6d3fe..f992b1938c034ab5bf7dffd27b200ba6a529a04f 100644
--- a/cc/layers/texture_layer_unittest.cc
+++ b/cc/layers/texture_layer_unittest.cc
@@ -643,15 +643,74 @@ class TextureLayerImplWithMailboxThreadedCallback : public LayerTreeTest {
bool synchronous_composite =
!HasImplThread() &&
!layer_tree_host()->GetSettings().single_thread_proxy_scheduler;
- // Allow relaim resources for this test so that mailboxes in the display
- // will be returned inside the commit that replaces them.
- bool force_disable_reclaim_resources = false;
return base::MakeUnique<TestCompositorFrameSink>(
compositor_context_provider, std::move(worker_context_provider),
shared_bitmap_manager(), gpu_memory_buffer_manager(),
layer_tree_host()->GetSettings().renderer_settings,
- ImplThreadTaskRunner(), synchronous_composite,
- force_disable_reclaim_resources);
+ ImplThreadTaskRunner(), synchronous_composite);
+ }
+
+ void AdvanceTestCase() {
+ ++test_case_;
+ switch (test_case_) {
+ case 1:
+ // Case #1: change mailbox before the commit. The old mailbox should be
+ // released immediately.
+ SetMailbox('2');
+ EXPECT_EQ(1, callback_count_);
+ PostSetNeedsCommitToMainThread();
+
+ // Case 2 does not rely on callbacks to advance.
+ pending_callback_ = false;
+ break;
+ case 2:
+ // Case #2: change mailbox after the commit (and draw), where the
+ // layer draws. The old mailbox should be released during the next
+ // commit.
+ SetMailbox('3');
+ EXPECT_EQ(1, callback_count_);
+
+ // Cases 3-5 rely on a callback to advance.
+ pending_callback_ = true;
+ break;
+ case 3:
+ EXPECT_EQ(2, callback_count_);
+ // Case #3: change mailbox when the layer doesn't draw. The old
+ // mailbox should be released during the next commit.
+ layer_->SetBounds(gfx::Size());
+ SetMailbox('4');
+ break;
+ case 4:
+ EXPECT_EQ(3, callback_count_);
+ // Case #4: release mailbox that was committed but never drawn. The
+ // old mailbox should be released during the next commit.
+ layer_->SetTextureMailbox(TextureMailbox(), nullptr);
+ break;
+ case 5:
+ EXPECT_EQ(4, callback_count_);
+ // Restore a mailbox for the next step.
+ SetMailbox('5');
+
+ // Cases 6 and 7 do not rely on callbacks to advance.
+ pending_callback_ = false;
+ break;
+ case 6:
+ // Case #5: remove layer from tree. Callback should *not* be called, the
+ // mailbox is returned to the main thread.
+ EXPECT_EQ(4, callback_count_);
+ layer_->RemoveFromParent();
+ break;
+ case 7:
+ EXPECT_EQ(4, callback_count_);
+ // Resetting the mailbox will call the callback now.
+ layer_->SetTextureMailbox(TextureMailbox(), nullptr);
+ EXPECT_EQ(5, callback_count_);
+ EndTest();
+ break;
+ default:
+ NOTREACHED();
+ break;
+ }
}
// Make sure callback is received on main and doesn't block the impl thread.
@@ -661,6 +720,10 @@ class TextureLayerImplWithMailboxThreadedCallback : public LayerTreeTest {
EXPECT_EQ(true, main_thread_.CalledOnValidThread());
EXPECT_FALSE(lost_resource);
++callback_count_;
+
+ // If we are waiting on a callback, advance now.
+ if (pending_callback_)
+ AdvanceTestCase();
}
void SetMailbox(char mailbox_char) {
@@ -696,58 +759,14 @@ class TextureLayerImplWithMailboxThreadedCallback : public LayerTreeTest {
SetMailbox('1');
EXPECT_EQ(0, callback_count_);
- // Case #1: change mailbox before the commit. The old mailbox should be
- // released immediately.
- SetMailbox('2');
- EXPECT_EQ(1, callback_count_);
- PostSetNeedsCommitToMainThread();
+ // Setup is complete - advance to test case 1.
+ AdvanceTestCase();
}
void DidCommit() override {
- ++commit_count_;
- switch (commit_count_) {
- case 1:
- // Case #2: change mailbox after the commit (and draw), where the
- // layer draws. The old mailbox should be released during the next
- // commit.
- SetMailbox('3');
- EXPECT_EQ(1, callback_count_);
- break;
- case 2:
- EXPECT_EQ(2, callback_count_);
- // Case #3: change mailbox when the layer doesn't draw. The old
- // mailbox should be released during the next commit.
- layer_->SetBounds(gfx::Size());
- SetMailbox('4');
- break;
- case 3:
- EXPECT_EQ(3, callback_count_);
- // Case #4: release mailbox that was committed but never drawn. The
- // old mailbox should be released during the next commit.
- layer_->SetTextureMailbox(TextureMailbox(), nullptr);
- break;
- case 4:
- EXPECT_EQ(4, callback_count_);
- // Restore a mailbox for the next step.
- SetMailbox('5');
- break;
- case 5:
- // Case #5: remove layer from tree. Callback should *not* be called, the
- // mailbox is returned to the main thread.
- EXPECT_EQ(4, callback_count_);
- layer_->RemoveFromParent();
- break;
- case 6:
- EXPECT_EQ(4, callback_count_);
- // Resetting the mailbox will call the callback now.
- layer_->SetTextureMailbox(TextureMailbox(), nullptr);
- EXPECT_EQ(5, callback_count_);
- EndTest();
- break;
- default:
- NOTREACHED();
- break;
- }
+ // If we are not waiting on a callback, advance now.
+ if (!pending_callback_)
+ AdvanceTestCase();
}
void AfterTest() override {}
@@ -755,7 +774,9 @@ class TextureLayerImplWithMailboxThreadedCallback : public LayerTreeTest {
private:
base::ThreadChecker main_thread_;
int callback_count_ = 0;
- int commit_count_ = 0;
+ int test_case_ = 0;
+ // Whether we are waiting on a callback to advance the test case.
+ bool pending_callback_ = false;
scoped_refptr<Layer> root_;
scoped_refptr<TextureLayer> layer_;
};
« no previous file with comments | « no previous file | cc/output/compositor_frame_sink.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698