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 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
125 SoftwareOutputDevice::DiscardBackbuffer(); | 125 SoftwareOutputDevice::DiscardBackbuffer(); |
126 discard_backbuffer_count_++; | 126 discard_backbuffer_count_++; |
127 } | 127 } |
128 | 128 |
129 void TestSoftwareOutputDevice::EnsureBackbuffer() { | 129 void TestSoftwareOutputDevice::EnsureBackbuffer() { |
130 SoftwareOutputDevice::EnsureBackbuffer(); | 130 SoftwareOutputDevice::EnsureBackbuffer(); |
131 ensure_backbuffer_count_++; | 131 ensure_backbuffer_count_++; |
132 } | 132 } |
133 | 133 |
134 TEST(OutputSurfaceTest, ClientPointerIndicatesBindToClientSuccess) { | 134 TEST(OutputSurfaceTest, ClientPointerIndicatesBindToClientSuccess) { |
135 TestOutputSurface output_surface(TestContextProvider::Create()); | 135 scoped_refptr<TestContextProvider> provider = TestContextProvider::Create(); |
| 136 TestOutputSurface output_surface(provider); |
136 EXPECT_FALSE(output_surface.HasClient()); | 137 EXPECT_FALSE(output_surface.HasClient()); |
137 | 138 |
138 FakeOutputSurfaceClient client; | 139 FakeOutputSurfaceClient client; |
139 EXPECT_TRUE(output_surface.BindToClient(&client)); | 140 EXPECT_TRUE(output_surface.BindToClient(&client)); |
140 EXPECT_TRUE(output_surface.HasClient()); | 141 EXPECT_TRUE(output_surface.HasClient()); |
141 EXPECT_FALSE(client.deferred_initialize_called()); | 142 EXPECT_FALSE(client.deferred_initialize_called()); |
142 | 143 |
143 // Verify DidLoseOutputSurface callback is hooked up correctly. | 144 // Verify DidLoseOutputSurface callback is hooked up correctly. |
144 EXPECT_FALSE(client.did_lose_output_surface_called()); | 145 EXPECT_FALSE(client.did_lose_output_surface_called()); |
145 output_surface.context_provider()->Context3d()->loseContextCHROMIUM( | 146 provider->TestContext3d()->loseContextCHROMIUM( |
146 GL_GUILTY_CONTEXT_RESET_ARB, GL_INNOCENT_CONTEXT_RESET_ARB); | 147 GL_GUILTY_CONTEXT_RESET_ARB, GL_INNOCENT_CONTEXT_RESET_ARB); |
147 EXPECT_TRUE(client.did_lose_output_surface_called()); | 148 EXPECT_TRUE(client.did_lose_output_surface_called()); |
148 } | 149 } |
149 | 150 |
150 TEST(OutputSurfaceTest, ClientPointerIndicatesBindToClientFailure) { | 151 TEST(OutputSurfaceTest, ClientPointerIndicatesBindToClientFailure) { |
151 scoped_refptr<TestContextProvider> context_provider = | 152 scoped_refptr<TestContextProvider> context_provider = |
152 TestContextProvider::Create(); | 153 TestContextProvider::Create(); |
153 | 154 |
154 // Lose the context so BindToClient fails. | 155 // Lose the context so BindToClient fails. |
155 context_provider->UnboundTestContext3d()->set_context_lost(true); | 156 context_provider->UnboundTestContext3d()->set_context_lost(true); |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
190 | 191 |
191 TEST_F(OutputSurfaceTestInitializeNewContext3d, Success) { | 192 TEST_F(OutputSurfaceTestInitializeNewContext3d, Success) { |
192 BindOutputSurface(); | 193 BindOutputSurface(); |
193 EXPECT_FALSE(client_.deferred_initialize_called()); | 194 EXPECT_FALSE(client_.deferred_initialize_called()); |
194 | 195 |
195 EXPECT_TRUE(output_surface_.InitializeNewContext3d(context_provider_)); | 196 EXPECT_TRUE(output_surface_.InitializeNewContext3d(context_provider_)); |
196 EXPECT_TRUE(client_.deferred_initialize_called()); | 197 EXPECT_TRUE(client_.deferred_initialize_called()); |
197 EXPECT_EQ(context_provider_, output_surface_.context_provider()); | 198 EXPECT_EQ(context_provider_, output_surface_.context_provider()); |
198 | 199 |
199 EXPECT_FALSE(client_.did_lose_output_surface_called()); | 200 EXPECT_FALSE(client_.did_lose_output_surface_called()); |
200 context_provider_->Context3d()->loseContextCHROMIUM( | 201 context_provider_->TestContext3d()->loseContextCHROMIUM( |
201 GL_GUILTY_CONTEXT_RESET_ARB, GL_INNOCENT_CONTEXT_RESET_ARB); | 202 GL_GUILTY_CONTEXT_RESET_ARB, GL_INNOCENT_CONTEXT_RESET_ARB); |
202 EXPECT_TRUE(client_.did_lose_output_surface_called()); | 203 EXPECT_TRUE(client_.did_lose_output_surface_called()); |
203 | 204 |
204 output_surface_.ReleaseGL(); | 205 output_surface_.ReleaseGL(); |
205 EXPECT_FALSE(output_surface_.context_provider()); | 206 EXPECT_FALSE(output_surface_.context_provider()); |
206 } | 207 } |
207 | 208 |
208 TEST_F(OutputSurfaceTestInitializeNewContext3d, Context3dMakeCurrentFails) { | 209 TEST_F(OutputSurfaceTestInitializeNewContext3d, Context3dMakeCurrentFails) { |
209 BindOutputSurface(); | 210 BindOutputSurface(); |
210 | 211 |
(...skipping 251 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
462 EXPECT_EQ(1, software_output_device->ensure_backbuffer_count()); | 463 EXPECT_EQ(1, software_output_device->ensure_backbuffer_count()); |
463 EXPECT_EQ(0, software_output_device->discard_backbuffer_count()); | 464 EXPECT_EQ(0, software_output_device->discard_backbuffer_count()); |
464 output_surface.DiscardBackbuffer(); | 465 output_surface.DiscardBackbuffer(); |
465 | 466 |
466 EXPECT_EQ(1, software_output_device->ensure_backbuffer_count()); | 467 EXPECT_EQ(1, software_output_device->ensure_backbuffer_count()); |
467 EXPECT_EQ(1, software_output_device->discard_backbuffer_count()); | 468 EXPECT_EQ(1, software_output_device->discard_backbuffer_count()); |
468 } | 469 } |
469 | 470 |
470 } // namespace | 471 } // namespace |
471 } // namespace cc | 472 } // namespace cc |
OLD | NEW |