OLD | NEW |
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/test/test_simple_task_runner.h" | 7 #include "base/test/test_simple_task_runner.h" |
8 #include "cc/output/managed_memory_policy.h" | 8 #include "cc/output/managed_memory_policy.h" |
9 #include "cc/output/output_surface_client.h" | 9 #include "cc/output/output_surface_client.h" |
10 #include "cc/output/software_output_device.h" | 10 #include "cc/output/software_output_device.h" |
(...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
136 TestOutputSurface output_surface(provider); | 136 TestOutputSurface output_surface(provider); |
137 EXPECT_FALSE(output_surface.HasClient()); | 137 EXPECT_FALSE(output_surface.HasClient()); |
138 | 138 |
139 FakeOutputSurfaceClient client; | 139 FakeOutputSurfaceClient client; |
140 EXPECT_TRUE(output_surface.BindToClient(&client)); | 140 EXPECT_TRUE(output_surface.BindToClient(&client)); |
141 EXPECT_TRUE(output_surface.HasClient()); | 141 EXPECT_TRUE(output_surface.HasClient()); |
142 EXPECT_FALSE(client.deferred_initialize_called()); | 142 EXPECT_FALSE(client.deferred_initialize_called()); |
143 | 143 |
144 // Verify DidLoseOutputSurface callback is hooked up correctly. | 144 // Verify DidLoseOutputSurface callback is hooked up correctly. |
145 EXPECT_FALSE(client.did_lose_output_surface_called()); | 145 EXPECT_FALSE(client.did_lose_output_surface_called()); |
146 provider->TestContext3d()->loseContextCHROMIUM( | 146 output_surface.context_provider()->ContextGL()->LoseContextCHROMIUM( |
147 GL_GUILTY_CONTEXT_RESET_ARB, GL_INNOCENT_CONTEXT_RESET_ARB); | 147 GL_GUILTY_CONTEXT_RESET_ARB, GL_INNOCENT_CONTEXT_RESET_ARB); |
| 148 output_surface.context_provider()->ContextGL()->Flush(); |
148 EXPECT_TRUE(client.did_lose_output_surface_called()); | 149 EXPECT_TRUE(client.did_lose_output_surface_called()); |
149 } | 150 } |
150 | 151 |
151 TEST(OutputSurfaceTest, ClientPointerIndicatesBindToClientFailure) { | 152 TEST(OutputSurfaceTest, ClientPointerIndicatesBindToClientFailure) { |
152 scoped_refptr<TestContextProvider> context_provider = | 153 scoped_refptr<TestContextProvider> context_provider = |
153 TestContextProvider::Create(); | 154 TestContextProvider::Create(); |
154 | 155 |
155 // Lose the context so BindToClient fails. | 156 // Lose the context so BindToClient fails. |
156 context_provider->UnboundTestContext3d()->set_context_lost(true); | 157 context_provider->UnboundTestContext3d()->set_context_lost(true); |
157 | 158 |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
191 | 192 |
192 TEST_F(OutputSurfaceTestInitializeNewContext3d, Success) { | 193 TEST_F(OutputSurfaceTestInitializeNewContext3d, Success) { |
193 BindOutputSurface(); | 194 BindOutputSurface(); |
194 EXPECT_FALSE(client_.deferred_initialize_called()); | 195 EXPECT_FALSE(client_.deferred_initialize_called()); |
195 | 196 |
196 EXPECT_TRUE(output_surface_.InitializeNewContext3d(context_provider_)); | 197 EXPECT_TRUE(output_surface_.InitializeNewContext3d(context_provider_)); |
197 EXPECT_TRUE(client_.deferred_initialize_called()); | 198 EXPECT_TRUE(client_.deferred_initialize_called()); |
198 EXPECT_EQ(context_provider_, output_surface_.context_provider()); | 199 EXPECT_EQ(context_provider_, output_surface_.context_provider()); |
199 | 200 |
200 EXPECT_FALSE(client_.did_lose_output_surface_called()); | 201 EXPECT_FALSE(client_.did_lose_output_surface_called()); |
201 context_provider_->TestContext3d()->loseContextCHROMIUM( | 202 context_provider_->ContextGL()->LoseContextCHROMIUM( |
202 GL_GUILTY_CONTEXT_RESET_ARB, GL_INNOCENT_CONTEXT_RESET_ARB); | 203 GL_GUILTY_CONTEXT_RESET_ARB, GL_INNOCENT_CONTEXT_RESET_ARB); |
| 204 context_provider_->ContextGL()->Flush(); |
203 EXPECT_TRUE(client_.did_lose_output_surface_called()); | 205 EXPECT_TRUE(client_.did_lose_output_surface_called()); |
204 | 206 |
205 output_surface_.ReleaseGL(); | 207 output_surface_.ReleaseGL(); |
206 EXPECT_FALSE(output_surface_.context_provider()); | 208 EXPECT_FALSE(output_surface_.context_provider()); |
207 } | 209 } |
208 | 210 |
209 TEST_F(OutputSurfaceTestInitializeNewContext3d, Context3dMakeCurrentFails) { | 211 TEST_F(OutputSurfaceTestInitializeNewContext3d, Context3dMakeCurrentFails) { |
210 BindOutputSurface(); | 212 BindOutputSurface(); |
211 | 213 |
212 context_provider_->UnboundTestContext3d()->set_context_lost(true); | 214 context_provider_->UnboundTestContext3d()->set_context_lost(true); |
(...skipping 250 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
463 EXPECT_EQ(1, software_output_device->ensure_backbuffer_count()); | 465 EXPECT_EQ(1, software_output_device->ensure_backbuffer_count()); |
464 EXPECT_EQ(0, software_output_device->discard_backbuffer_count()); | 466 EXPECT_EQ(0, software_output_device->discard_backbuffer_count()); |
465 output_surface.DiscardBackbuffer(); | 467 output_surface.DiscardBackbuffer(); |
466 | 468 |
467 EXPECT_EQ(1, software_output_device->ensure_backbuffer_count()); | 469 EXPECT_EQ(1, software_output_device->ensure_backbuffer_count()); |
468 EXPECT_EQ(1, software_output_device->discard_backbuffer_count()); | 470 EXPECT_EQ(1, software_output_device->discard_backbuffer_count()); |
469 } | 471 } |
470 | 472 |
471 } // namespace | 473 } // namespace |
472 } // namespace cc | 474 } // namespace cc |
OLD | NEW |