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

Unified Diff: cc/trees/layer_tree_host_unittest_context.cc

Issue 812543002: Update from https://crrev.com/308331 (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Created 6 years 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.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 b646e6adc52d6d009066dd01672f22d9ec02879b..cc4f28fb05fad1fcb1b638fc0338e85e89a5e199 100644
--- a/cc/trees/layer_tree_host_unittest_context.cc
+++ b/cc/trees/layer_tree_host_unittest_context.cc
@@ -17,6 +17,7 @@
#include "cc/layers/texture_layer_impl.h"
#include "cc/output/filter_operations.h"
#include "cc/resources/single_release_callback.h"
+#include "cc/test/failure_output_surface.h"
#include "cc/test/fake_content_layer.h"
#include "cc/test/fake_content_layer_client.h"
#include "cc/test/fake_content_layer_impl.h"
@@ -74,12 +75,11 @@ class LayerTreeHostContextTest : public LayerTreeTest {
return TestWebGraphicsContext3D::Create();
}
- scoped_ptr<FakeOutputSurface> CreateFakeOutputSurface(
- bool fallback) override {
+ scoped_ptr<FakeOutputSurface> CreateFakeOutputSurface() override {
if (times_to_fail_create_) {
--times_to_fail_create_;
ExpectCreateToFail();
- return nullptr;
+ return make_scoped_ptr(new FailureOutputSurface(delegating_renderer()));
}
scoped_ptr<TestWebGraphicsContext3D> context3d = CreateContext3d();
@@ -167,22 +167,22 @@ class LayerTreeHostContextTestLostContextSucceeds
void BeginTest() override { PostSetNeedsCommitToMainThread(); }
- void RequestNewOutputSurface(bool fallback) override {
+ void RequestNewOutputSurface() override {
if (async_output_surface_creation_) {
MainThreadTaskRunner()->PostTask(
- FROM_HERE,
- base::Bind(&LayerTreeHostContextTestLostContextSucceeds::
- CreateAndSetOutputSurface,
- base::Unretained(this),
- fallback));
+ FROM_HERE, base::Bind(&LayerTreeHostContextTestLostContextSucceeds::
+ CreateAndSetOutputSurface,
+ base::Unretained(this)));
} else {
- CreateAndSetOutputSurface(fallback);
+ CreateAndSetOutputSurface();
}
}
- void CreateAndSetOutputSurface(bool fallback) {
- layer_tree_host()->SetOutputSurface(
- LayerTreeHostContextTest::CreateOutputSurface(fallback));
+ void CreateAndSetOutputSurface() {
+ scoped_ptr<OutputSurface> surface(
+ LayerTreeHostContextTest::CreateOutputSurface());
+ CHECK(surface);
+ layer_tree_host()->SetOutputSurface(surface.Pass());
}
void DidInitializeOutputSurface() override {
@@ -357,7 +357,7 @@ class LayerTreeHostClientNotReadyDoesNotCreateOutputSurface
EndTest();
}
- scoped_ptr<OutputSurface> CreateOutputSurface(bool fallback) override {
+ scoped_ptr<OutputSurface> CreateOutputSurface() override {
EXPECT_TRUE(false);
return nullptr;
}
@@ -380,7 +380,7 @@ class MultipleCompositeDoesNotCreateOutputSurface
settings->single_thread_proxy_scheduler = false;
}
- void RequestNewOutputSurface(bool fallback) override {
+ void RequestNewOutputSurface() override {
EXPECT_GE(1, ++request_count_);
EndTest();
}
@@ -390,7 +390,7 @@ class MultipleCompositeDoesNotCreateOutputSurface
layer_tree_host()->Composite(base::TimeTicks());
}
- scoped_ptr<OutputSurface> CreateOutputSurface(bool fallback) override {
+ scoped_ptr<OutputSurface> CreateOutputSurface() override {
EXPECT_TRUE(false);
return nullptr;
}
@@ -414,13 +414,12 @@ class FailedCreateDoesNotCreateExtraOutputSurface
settings->single_thread_proxy_scheduler = false;
}
- void RequestNewOutputSurface(bool fallback) override {
+ void RequestNewOutputSurface() override {
if (request_count_ == 0) {
ExpectCreateToFail();
- layer_tree_host()->SetOutputSurface(nullptr);
+ layer_tree_host()->SetOutputSurface(
+ make_scoped_ptr(new FailureOutputSurface(false)));
}
- EXPECT_GE(2, ++request_count_);
- EndTest();
}
void BeginTest() override {
@@ -428,13 +427,14 @@ class FailedCreateDoesNotCreateExtraOutputSurface
layer_tree_host()->Composite(base::TimeTicks());
}
- scoped_ptr<OutputSurface> CreateOutputSurface(bool fallback) override {
- EXPECT_TRUE(false);
- return nullptr;
- }
-
void DidInitializeOutputSurface() override { EXPECT_TRUE(false); }
+ void DidFailToInitializeOutputSurface() override {
+ LayerTreeHostContextTest::DidFailToInitializeOutputSurface();
+ EXPECT_GE(2, ++request_count_);
+ EndTest();
+ }
+
void AfterTest() override {}
int request_count_;
@@ -452,19 +452,18 @@ class LayerTreeHostContextTestCommitAfterDelayedOutputSurface
settings->single_thread_proxy_scheduler = false;
}
- void RequestNewOutputSurface(bool fallback) override {
+ void RequestNewOutputSurface() override {
MainThreadTaskRunner()->PostTask(
FROM_HERE,
base::Bind(&LayerTreeHostContextTestCommitAfterDelayedOutputSurface::
CreateAndSetOutputSurface,
- base::Unretained(this),
- fallback));
+ base::Unretained(this)));
}
- void CreateAndSetOutputSurface(bool fallback) {
+ void CreateAndSetOutputSurface() {
creating_output_ = true;
layer_tree_host()->SetOutputSurface(
- LayerTreeHostContextTest::CreateOutputSurface(fallback));
+ LayerTreeHostContextTest::CreateOutputSurface());
}
void BeginTest() override { layer_tree_host()->Composite(base::TimeTicks()); }
@@ -492,9 +491,9 @@ class LayerTreeHostContextTestAvoidUnnecessaryComposite
settings->single_thread_proxy_scheduler = false;
}
- void RequestNewOutputSurface(bool fallback) override {
+ void RequestNewOutputSurface() override {
layer_tree_host()->SetOutputSurface(
- LayerTreeHostContextTest::CreateOutputSurface(fallback));
+ LayerTreeHostContextTest::CreateOutputSurface());
EndTest();
}
@@ -572,35 +571,16 @@ class LayerTreeHostContextTestLostContextSucceedsWithContent
SINGLE_AND_MULTI_THREAD_TEST_F(
LayerTreeHostContextTestLostContextSucceedsWithContent);
-class LayerTreeHostContextTestCreateOutputSurfaceFails
+class LayerTreeHostContextTestCreateOutputSurfaceFailsOnce
: public LayerTreeHostContextTest {
public:
- // Run a test that initially fails OutputSurface creation |times_to_fail|
- // times. If |expect_fallback_attempt| is |true|, an attempt to create a
- // fallback/software OutputSurface is expected to occur.
- LayerTreeHostContextTestCreateOutputSurfaceFails(int times_to_fail,
- bool expect_fallback_attempt)
- : times_to_fail_(times_to_fail),
- expect_fallback_attempt_(expect_fallback_attempt),
- did_attempt_fallback_(false),
- times_initialized_(0) {
+ LayerTreeHostContextTestCreateOutputSurfaceFailsOnce()
+ : times_to_fail_(1), times_initialized_(0) {
times_to_fail_create_ = times_to_fail_;
}
void BeginTest() override { PostSetNeedsCommitToMainThread(); }
- scoped_ptr<FakeOutputSurface> CreateFakeOutputSurface(
- bool fallback) override {
- scoped_ptr<FakeOutputSurface> surface =
- LayerTreeHostContextTest::CreateFakeOutputSurface(fallback);
-
- if (surface)
- EXPECT_EQ(times_to_fail_, times_create_failed_);
-
- did_attempt_fallback_ = fallback;
- return surface.Pass();
- }
-
void DidInitializeOutputSurface() override { times_initialized_++; }
void DrawLayersOnThread(LayerTreeHostImpl* host_impl) override { EndTest(); }
@@ -608,38 +588,16 @@ class LayerTreeHostContextTestCreateOutputSurfaceFails
void AfterTest() override {
EXPECT_EQ(times_to_fail_, times_create_failed_);
EXPECT_NE(0, times_initialized_);
- EXPECT_EQ(expect_fallback_attempt_, did_attempt_fallback_);
}
private:
int times_to_fail_;
- bool expect_fallback_attempt_;
- bool did_attempt_fallback_;
int times_initialized_;
};
-class LayerTreeHostContextTestCreateOutputSurfaceFailsOnce
- : public LayerTreeHostContextTestCreateOutputSurfaceFails {
- public:
- LayerTreeHostContextTestCreateOutputSurfaceFailsOnce()
- : LayerTreeHostContextTestCreateOutputSurfaceFails(1, false) {}
-};
-
SINGLE_AND_MULTI_THREAD_TEST_F(
LayerTreeHostContextTestCreateOutputSurfaceFailsOnce);
-// After 4 failures we expect an attempt to create a fallback/software
-// OutputSurface.
-class LayerTreeHostContextTestCreateOutputSurfaceFailsWithFallback
- : public LayerTreeHostContextTestCreateOutputSurfaceFails {
- public:
- LayerTreeHostContextTestCreateOutputSurfaceFailsWithFallback()
- : LayerTreeHostContextTestCreateOutputSurfaceFails(4, true) {}
-};
-
-SINGLE_AND_MULTI_THREAD_TEST_F(
- LayerTreeHostContextTestCreateOutputSurfaceFailsWithFallback);
-
class LayerTreeHostContextTestLostContextAndEvictTextures
: public LayerTreeHostContextTest {
public:
@@ -1118,15 +1076,14 @@ class LayerTreeHostContextTestDontUseLostResources
return draw_result;
}
- scoped_ptr<FakeOutputSurface> CreateFakeOutputSurface(
- bool fallback) override {
+ scoped_ptr<FakeOutputSurface> CreateFakeOutputSurface() override {
// This will get called twice:
// First when we create the initial output surface...
if (layer_tree_host()->source_frame_number() > 0) {
// ... and then again after we forced the context to be lost.
lost_context_ = true;
}
- return LayerTreeHostContextTest::CreateFakeOutputSurface(fallback);
+ return LayerTreeHostContextTest::CreateFakeOutputSurface();
}
void DidCommitAndDrawFrame() override {
« no previous file with comments | « cc/trees/layer_tree_host_unittest.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