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

Unified Diff: cc/trees/layer_tree_host_unittest_context.cc

Issue 895853003: Update from https://crrev.com/314320 (Closed) Base URL: https://github.com/domokit/mojo.git@master
Patch Set: Created 5 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 | « cc/trees/layer_tree_host_unittest_animation.cc ('k') | cc/trees/layer_tree_host_unittest_copyrequest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 cc4f28fb05fad1fcb1b638fc0338e85e89a5e199..fb0c9c8c7c8cfaa6665560cbbbf730b2b12db71d 100644
--- a/cc/trees/layer_tree_host_unittest_context.cc
+++ b/cc/trees/layer_tree_host_unittest_context.cc
@@ -404,40 +404,56 @@ class MultipleCompositeDoesNotCreateOutputSurface
SINGLE_THREAD_NOIMPL_TEST_F(MultipleCompositeDoesNotCreateOutputSurface);
+// This test makes sure that once a SingleThreadProxy issues a
+// DidFailToInitializeOutputSurface, that future Composite calls will not
+// trigger additional requests for output surfaces.
class FailedCreateDoesNotCreateExtraOutputSurface
: public LayerTreeHostContextTest {
public:
FailedCreateDoesNotCreateExtraOutputSurface()
- : LayerTreeHostContextTest(), request_count_(0) {}
+ : LayerTreeHostContextTest(), num_requests_(0), has_failed_(false) {}
void InitializeSettings(LayerTreeSettings* settings) override {
settings->single_thread_proxy_scheduler = false;
}
void RequestNewOutputSurface() override {
- if (request_count_ == 0) {
- ExpectCreateToFail();
- layer_tree_host()->SetOutputSurface(
- make_scoped_ptr(new FailureOutputSurface(false)));
- }
+ num_requests_++;
+ // There should be one initial request and then one request from
+ // the LayerTreeTest test hooks DidFailToInitializeOutputSurface (which is
+ // hard to skip). This second request is just ignored and is test cruft.
+ EXPECT_LE(num_requests_, 2);
+ if (num_requests_ > 1)
+ return;
+ ExpectCreateToFail();
+ layer_tree_host()->SetOutputSurface(
+ make_scoped_ptr(new FailureOutputSurface(false)));
}
void BeginTest() override {
+ // First composite tries to create a surface.
layer_tree_host()->Composite(base::TimeTicks());
+ EXPECT_EQ(num_requests_, 2);
+ EXPECT_TRUE(has_failed_);
+
+ // Second composite should not request or fail.
layer_tree_host()->Composite(base::TimeTicks());
+ EXPECT_EQ(num_requests_, 2);
+ EndTest();
}
void DidInitializeOutputSurface() override { EXPECT_TRUE(false); }
void DidFailToInitializeOutputSurface() override {
LayerTreeHostContextTest::DidFailToInitializeOutputSurface();
- EXPECT_GE(2, ++request_count_);
- EndTest();
+ EXPECT_FALSE(has_failed_);
+ has_failed_ = true;
}
void AfterTest() override {}
- int request_count_;
+ int num_requests_;
+ bool has_failed_;
};
SINGLE_THREAD_NOIMPL_TEST_F(FailedCreateDoesNotCreateExtraOutputSurface);
@@ -1694,12 +1710,7 @@ class LayerTreeHostContextTestLoseAfterSendingBeginMainFrame
deferred_ = true;
// Defer commits before the BeginFrame arrives, causing it to be delayed.
- MainThreadTaskRunner()->PostTask(
- FROM_HERE,
- base::Bind(&LayerTreeHostContextTestLoseAfterSendingBeginMainFrame::
- DeferCommitsOnMainThread,
- base::Unretained(this),
- true));
+ PostSetDeferCommitsToMainThread(true);
// Meanwhile, lose the context while we are in defer commits.
ImplThreadTaskRunner()->PostTask(
FROM_HERE,
@@ -1712,16 +1723,7 @@ class LayerTreeHostContextTestLoseAfterSendingBeginMainFrame
LoseContext();
// After losing the context, stop deferring commits.
- MainThreadTaskRunner()->PostTask(
- FROM_HERE,
- base::Bind(&LayerTreeHostContextTestLoseAfterSendingBeginMainFrame::
- DeferCommitsOnMainThread,
- base::Unretained(this),
- false));
- }
-
- void DeferCommitsOnMainThread(bool defer_commits) {
- layer_tree_host()->SetDeferCommits(defer_commits);
+ PostSetDeferCommitsToMainThread(false);
}
void WillBeginMainFrame() override {
« no previous file with comments | « cc/trees/layer_tree_host_unittest_animation.cc ('k') | cc/trees/layer_tree_host_unittest_copyrequest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698