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

Side by Side Diff: cc/output/output_surface_unittest.cc

Issue 2009443002: Revert of Consolidate OutputSurface constructors into GL vs Vulkan. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 6 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 unified diff | Download patch
« no previous file with comments | « cc/output/output_surface.cc ('k') | cc/output/overlay_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "cc/output/output_surface.h" 5 #include "cc/output/output_surface.h"
6 6
7 #include "base/memory/ptr_util.h" 7 #include "base/memory/ptr_util.h"
8 #include "base/test/test_simple_task_runner.h" 8 #include "base/test/test_simple_task_runner.h"
9 #include "cc/output/managed_memory_policy.h" 9 #include "cc/output/managed_memory_policy.h"
10 #include "cc/output/output_surface_client.h" 10 #include "cc/output/output_surface_client.h"
11 #include "cc/output/software_output_device.h" 11 #include "cc/output/software_output_device.h"
12 #include "cc/test/begin_frame_args_test.h" 12 #include "cc/test/begin_frame_args_test.h"
13 #include "cc/test/fake_output_surface.h" 13 #include "cc/test/fake_output_surface.h"
14 #include "cc/test/fake_output_surface_client.h" 14 #include "cc/test/fake_output_surface_client.h"
15 #include "cc/test/test_context_provider.h" 15 #include "cc/test/test_context_provider.h"
16 #include "cc/test/test_web_graphics_context_3d.h" 16 #include "cc/test/test_web_graphics_context_3d.h"
17 #include "gpu/GLES2/gl2extchromium.h" 17 #include "gpu/GLES2/gl2extchromium.h"
18 #include "testing/gtest/include/gtest/gtest.h" 18 #include "testing/gtest/include/gtest/gtest.h"
19 19
20 namespace cc { 20 namespace cc {
21 namespace { 21 namespace {
22 22
23 class TestOutputSurface : public OutputSurface { 23 class TestOutputSurface : public OutputSurface {
24 public: 24 public:
25 explicit TestOutputSurface(scoped_refptr<ContextProvider> context_provider) 25 explicit TestOutputSurface(scoped_refptr<ContextProvider> context_provider)
26 : OutputSurface(std::move(context_provider), nullptr, nullptr) {} 26 : OutputSurface(context_provider) {}
27 27
28 TestOutputSurface(scoped_refptr<ContextProvider> context_provider, 28 TestOutputSurface(scoped_refptr<ContextProvider> context_provider,
29 scoped_refptr<ContextProvider> worker_context_provider) 29 scoped_refptr<ContextProvider> worker_context_provider)
30 : OutputSurface(std::move(context_provider), 30 : OutputSurface(worker_context_provider) {}
31 std::move(worker_context_provider),
32 nullptr) {}
33 31
34 explicit TestOutputSurface( 32 explicit TestOutputSurface(
35 std::unique_ptr<SoftwareOutputDevice> software_device) 33 std::unique_ptr<SoftwareOutputDevice> software_device)
36 : OutputSurface(nullptr, nullptr, std::move(software_device)) {} 34 : OutputSurface(std::move(software_device)) {}
37 35
38 TestOutputSurface(scoped_refptr<ContextProvider> context_provider, 36 TestOutputSurface(scoped_refptr<ContextProvider> context_provider,
39 std::unique_ptr<SoftwareOutputDevice> software_device) 37 std::unique_ptr<SoftwareOutputDevice> software_device)
40 : OutputSurface(std::move(context_provider), 38 : OutputSurface(context_provider, std::move(software_device)) {}
41 nullptr,
42 std::move(software_device)) {}
43 39
44 void SwapBuffers(CompositorFrame* frame) override { 40 void SwapBuffers(CompositorFrame* frame) override {
45 client_->DidSwapBuffers(); 41 client_->DidSwapBuffers();
46 client_->DidSwapBuffersComplete(); 42 client_->DidSwapBuffersComplete();
47 } 43 }
48 44
49 void DidSwapBuffersForTesting() { client_->DidSwapBuffers(); } 45 void DidSwapBuffersForTesting() { client_->DidSwapBuffers(); }
50 46
51 void OnSwapBuffersCompleteForTesting() { client_->DidSwapBuffersComplete(); } 47 void OnSwapBuffersCompleteForTesting() { client_->DidSwapBuffersComplete(); }
52 48
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
114 EXPECT_TRUE(output_surface.HasClient()); 110 EXPECT_TRUE(output_surface.HasClient());
115 111
116 // Verify DidLoseOutputSurface callback is hooked up correctly. 112 // Verify DidLoseOutputSurface callback is hooked up correctly.
117 EXPECT_FALSE(client.did_lose_output_surface_called()); 113 EXPECT_FALSE(client.did_lose_output_surface_called());
118 output_surface.context_provider()->ContextGL()->LoseContextCHROMIUM( 114 output_surface.context_provider()->ContextGL()->LoseContextCHROMIUM(
119 GL_GUILTY_CONTEXT_RESET_ARB, GL_INNOCENT_CONTEXT_RESET_ARB); 115 GL_GUILTY_CONTEXT_RESET_ARB, GL_INNOCENT_CONTEXT_RESET_ARB);
120 output_surface.context_provider()->ContextGL()->Flush(); 116 output_surface.context_provider()->ContextGL()->Flush();
121 EXPECT_TRUE(client.did_lose_output_surface_called()); 117 EXPECT_TRUE(client.did_lose_output_surface_called());
122 } 118 }
123 119
124 // TODO(danakj): Add a test for worker context failure as well when
125 // OutputSurface creates/binds it.
126 TEST(OutputSurfaceTest, ClientPointerIndicatesBindToClientFailure) { 120 TEST(OutputSurfaceTest, ClientPointerIndicatesBindToClientFailure) {
127 scoped_refptr<TestContextProvider> context_provider = 121 scoped_refptr<TestContextProvider> context_provider =
128 TestContextProvider::Create(); 122 TestContextProvider::Create();
129 123
130 // Lose the context so BindToClient fails. 124 // Lose the context so BindToClient fails.
131 context_provider->UnboundTestContext3d()->set_context_lost(true); 125 context_provider->UnboundTestContext3d()->set_context_lost(true);
132 126
133 TestOutputSurface output_surface(context_provider); 127 TestOutputSurface output_surface(context_provider);
134 EXPECT_FALSE(output_surface.HasClient()); 128 EXPECT_FALSE(output_surface.HasClient());
135 129
136 FakeOutputSurfaceClient client; 130 FakeOutputSurfaceClient client;
131 EXPECT_FALSE(output_surface.BindToClient(&client));
132 EXPECT_FALSE(output_surface.HasClient());
133 }
134
135 TEST(OutputSurfaceTest, ClientPointerIndicatesWorkerBindToClientFailure) {
136 scoped_refptr<TestContextProvider> context_provider =
137 TestContextProvider::Create();
138 scoped_refptr<TestContextProvider> worker_context_provider =
139 TestContextProvider::Create();
140
141 // Lose the context so BindToClient fails.
142 worker_context_provider->UnboundTestContext3d()->set_context_lost(true);
143
144 TestOutputSurface output_surface(context_provider, worker_context_provider);
145 EXPECT_FALSE(output_surface.HasClient());
146
147 FakeOutputSurfaceClient client;
137 EXPECT_FALSE(output_surface.BindToClient(&client)); 148 EXPECT_FALSE(output_surface.BindToClient(&client));
138 EXPECT_FALSE(output_surface.HasClient()); 149 EXPECT_FALSE(output_surface.HasClient());
139 } 150 }
140 151
141 TEST(OutputSurfaceTest, SoftwareOutputDeviceBackbufferManagement) { 152 TEST(OutputSurfaceTest, SoftwareOutputDeviceBackbufferManagement) {
142 TestSoftwareOutputDevice* software_output_device = 153 TestSoftwareOutputDevice* software_output_device =
143 new TestSoftwareOutputDevice(); 154 new TestSoftwareOutputDevice();
144 155
145 // TestOutputSurface now owns software_output_device and has responsibility to 156 // TestOutputSurface now owns software_output_device and has responsibility to
146 // free it. 157 // free it.
147 TestOutputSurface output_surface(base::WrapUnique(software_output_device)); 158 TestOutputSurface output_surface(base::WrapUnique(software_output_device));
148 159
149 EXPECT_EQ(0, software_output_device->ensure_backbuffer_count()); 160 EXPECT_EQ(0, software_output_device->ensure_backbuffer_count());
150 EXPECT_EQ(0, software_output_device->discard_backbuffer_count()); 161 EXPECT_EQ(0, software_output_device->discard_backbuffer_count());
151 162
152 output_surface.EnsureBackbuffer(); 163 output_surface.EnsureBackbuffer();
153 EXPECT_EQ(1, software_output_device->ensure_backbuffer_count()); 164 EXPECT_EQ(1, software_output_device->ensure_backbuffer_count());
154 EXPECT_EQ(0, software_output_device->discard_backbuffer_count()); 165 EXPECT_EQ(0, software_output_device->discard_backbuffer_count());
155 output_surface.DiscardBackbuffer(); 166 output_surface.DiscardBackbuffer();
156 167
157 EXPECT_EQ(1, software_output_device->ensure_backbuffer_count()); 168 EXPECT_EQ(1, software_output_device->ensure_backbuffer_count());
158 EXPECT_EQ(1, software_output_device->discard_backbuffer_count()); 169 EXPECT_EQ(1, software_output_device->discard_backbuffer_count());
159 } 170 }
160 171
161 } // namespace 172 } // namespace
162 } // namespace cc 173 } // namespace cc
OLDNEW
« no previous file with comments | « cc/output/output_surface.cc ('k') | cc/output/overlay_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698