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

Unified Diff: cc/trees/layer_tree_host_unittest.cc

Issue 2171143002: cc: Get rid of non-delegated rendering in most cc unit tests. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@killdirecttests
Patch Set: fakeoutputsurface: no-constructor Created 4 years, 5 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_impl_unittest.cc ('k') | cc/trees/layer_tree_host_unittest_context.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.cc
diff --git a/cc/trees/layer_tree_host_unittest.cc b/cc/trees/layer_tree_host_unittest.cc
index d76c9dfdfb654eaf70a37fc5df6de8af058899df..baa1618b0a25656e304f5e75cac046d19eb1491c 100644
--- a/cc/trees/layer_tree_host_unittest.cc
+++ b/cc/trees/layer_tree_host_unittest.cc
@@ -73,27 +73,7 @@ using testing::Mock;
namespace cc {
namespace {
-class LayerTreeHostTest : public LayerTreeTest {
- protected:
- // These tests are not pixel tests, and they use a fake output surface,
- // while storing pointers to the test-types for tests to poke at.
- std::unique_ptr<OutputSurface> CreateOutputSurface() override {
- auto context = TestContextProvider::Create();
- context_provider_ = context.get();
- auto ret = delegating_renderer()
- ? FakeOutputSurface::CreateDelegating3d(std::move(context))
- : FakeOutputSurface::Create3d(std::move(context));
- output_surface_ = ret.get();
- return std::move(ret);
- }
-
- FakeOutputSurface* fake_output_surface() { return output_surface_; }
- TestContextProvider* test_context_provider() { return context_provider_; }
-
- private:
- FakeOutputSurface* output_surface_ = nullptr;
- TestContextProvider* context_provider_ = nullptr;
-};
+class LayerTreeHostTest : public LayerTreeTest {};
class LayerTreeHostTestHasImplThreadTest : public LayerTreeHostTest {
public:
@@ -2979,7 +2959,9 @@ class LayerTreeHostTestUIResource : public LayerTreeHostTest {
}
void DidActivateTreeOnThread(LayerTreeHostImpl* impl) override {
- auto* context = test_context_provider()->TestContext3d();
+ auto* context = static_cast<TestContextProvider*>(
+ impl->output_surface()->context_provider())
+ ->TestContext3d();
int frame = impl->active_tree()->source_frame_number();
switch (frame) {
@@ -4040,13 +4022,13 @@ class LayerTreeHostTestTreeActivationCallback : public LayerTreeHostTest {
case 1:
EXPECT_EQ(0, callback_count_);
callback_count_ = 0;
- SetCallback(true);
+ SetCallback(host_impl, true);
PostSetNeedsCommitToMainThread();
break;
case 2:
EXPECT_EQ(1, callback_count_);
callback_count_ = 0;
- SetCallback(false);
+ SetCallback(host_impl, false);
PostSetNeedsCommitToMainThread();
break;
case 3:
@@ -4065,8 +4047,8 @@ class LayerTreeHostTestTreeActivationCallback : public LayerTreeHostTest {
void AfterTest() override { EXPECT_EQ(3, num_commits_); }
- void SetCallback(bool enable) {
- fake_output_surface()->SetTreeActivationCallback(
+ void SetCallback(LayerTreeHostImpl* host_impl, bool enable) {
+ host_impl->SetTreeActivationCallback(
enable
? base::Bind(
&LayerTreeHostTestTreeActivationCallback::ActivationCallback,
@@ -4660,9 +4642,9 @@ class LayerTreeHostTestKeepSwapPromise : public LayerTreeHostTest {
base::AutoLock lock(swap_promise_result_.lock);
EXPECT_FALSE(swap_promise_result_.did_activate_called);
EXPECT_FALSE(swap_promise_result_.did_swap_called);
- SetCallback(true);
+ SetCallback(host_impl, true);
} else {
- SetCallback(false);
+ SetCallback(host_impl, false);
}
}
}
@@ -4681,8 +4663,8 @@ class LayerTreeHostTestKeepSwapPromise : public LayerTreeHostTest {
EXPECT_TRUE(swap_promise_result_.did_activate_called);
}
- void SetCallback(bool enable) {
- fake_output_surface()->SetTreeActivationCallback(
+ void SetCallback(LayerTreeHostImpl* host_impl, bool enable) {
+ host_impl->SetTreeActivationCallback(
enable
? base::Bind(&LayerTreeHostTestKeepSwapPromise::ActivationCallback,
base::Unretained(this))
@@ -6804,6 +6786,14 @@ MULTI_THREAD_TEST_F(LayerTreeHostTestDestroyWhileInitializingOutputSurface);
// frame's metadata.
class LayerTreeHostTestPaintedDeviceScaleFactor : public LayerTreeHostTest {
protected:
+ LayerTreeHostTestPaintedDeviceScaleFactor() = default;
+
+ std::unique_ptr<OutputSurface> CreateOutputSurface() override {
+ auto ret = FakeOutputSurface::CreateDelegating3d();
+ fake_output_surface_ = ret.get();
+ return std::move(ret);
+ }
+
void BeginTest() override {
layer_tree_host()->SetPaintedDeviceScaleFactor(2.0f);
EXPECT_EQ(1.0f, layer_tree_host()->device_scale_factor());
@@ -6818,11 +6808,13 @@ class LayerTreeHostTestPaintedDeviceScaleFactor : public LayerTreeHostTest {
void SwapBuffersCompleteOnThread() override {
EXPECT_EQ(
2.0f,
- fake_output_surface()->last_sent_frame()->metadata.device_scale_factor);
+ fake_output_surface_->last_sent_frame()->metadata.device_scale_factor);
EndTest();
}
void AfterTest() override {}
+
+ FakeOutputSurface* fake_output_surface_ = nullptr;
};
SINGLE_AND_MULTI_THREAD_TEST_F(LayerTreeHostTestPaintedDeviceScaleFactor);
« no previous file with comments | « cc/trees/layer_tree_host_impl_unittest.cc ('k') | cc/trees/layer_tree_host_unittest_context.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698