| 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 22 matching lines...) Expand all Loading... |
| 33 override_retroactive_period_(false) {} | 33 override_retroactive_period_(false) {} |
| 34 | 34 |
| 35 TestOutputSurface(scoped_refptr<ContextProvider> context_provider, | 35 TestOutputSurface(scoped_refptr<ContextProvider> context_provider, |
| 36 scoped_ptr<SoftwareOutputDevice> software_device) | 36 scoped_ptr<SoftwareOutputDevice> software_device) |
| 37 : OutputSurface(context_provider, software_device.Pass()), | 37 : OutputSurface(context_provider, software_device.Pass()), |
| 38 retroactive_begin_frame_deadline_enabled_(false), | 38 retroactive_begin_frame_deadline_enabled_(false), |
| 39 override_retroactive_period_(false) {} | 39 override_retroactive_period_(false) {} |
| 40 | 40 |
| 41 bool InitializeNewContext3d( | 41 bool InitializeNewContext3d( |
| 42 scoped_refptr<ContextProvider> new_context_provider) { | 42 scoped_refptr<ContextProvider> new_context_provider) { |
| 43 return InitializeAndSetContext3d(new_context_provider, | 43 return InitializeAndSetContext3d(new_context_provider); |
| 44 scoped_refptr<ContextProvider>()); | |
| 45 } | 44 } |
| 46 | 45 |
| 47 using OutputSurface::ReleaseGL; | 46 using OutputSurface::ReleaseGL; |
| 48 | 47 |
| 49 void CommitVSyncParametersForTesting(base::TimeTicks timebase, | 48 void CommitVSyncParametersForTesting(base::TimeTicks timebase, |
| 50 base::TimeDelta interval) { | 49 base::TimeDelta interval) { |
| 51 CommitVSyncParameters(timebase, interval); | 50 CommitVSyncParameters(timebase, interval); |
| 52 } | 51 } |
| 53 | 52 |
| 54 void BeginFrameForTesting() { | 53 void BeginFrameForTesting() { |
| (...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 203 EXPECT_FALSE(output_surface_.context_provider()); | 202 EXPECT_FALSE(output_surface_.context_provider()); |
| 204 } | 203 } |
| 205 | 204 |
| 206 TEST_F(OutputSurfaceTestInitializeNewContext3d, Context3dMakeCurrentFails) { | 205 TEST_F(OutputSurfaceTestInitializeNewContext3d, Context3dMakeCurrentFails) { |
| 207 BindOutputSurface(); | 206 BindOutputSurface(); |
| 208 | 207 |
| 209 context_provider_->UnboundTestContext3d()->set_context_lost(true); | 208 context_provider_->UnboundTestContext3d()->set_context_lost(true); |
| 210 InitializeNewContextExpectFail(); | 209 InitializeNewContextExpectFail(); |
| 211 } | 210 } |
| 212 | 211 |
| 213 TEST_F(OutputSurfaceTestInitializeNewContext3d, ClientDeferredInitializeFails) { | |
| 214 BindOutputSurface(); | |
| 215 client_.set_deferred_initialize_result(false); | |
| 216 InitializeNewContextExpectFail(); | |
| 217 } | |
| 218 | |
| 219 TEST(OutputSurfaceTest, BeginFrameEmulation) { | 212 TEST(OutputSurfaceTest, BeginFrameEmulation) { |
| 220 TestOutputSurface output_surface(TestContextProvider::Create()); | 213 TestOutputSurface output_surface(TestContextProvider::Create()); |
| 221 EXPECT_FALSE(output_surface.HasClient()); | 214 EXPECT_FALSE(output_surface.HasClient()); |
| 222 | 215 |
| 223 FakeOutputSurfaceClient client; | 216 FakeOutputSurfaceClient client; |
| 224 EXPECT_TRUE(output_surface.BindToClient(&client)); | 217 EXPECT_TRUE(output_surface.BindToClient(&client)); |
| 225 EXPECT_TRUE(output_surface.HasClient()); | 218 EXPECT_TRUE(output_surface.HasClient()); |
| 226 EXPECT_FALSE(client.deferred_initialize_called()); | 219 EXPECT_FALSE(client.deferred_initialize_called()); |
| 227 | 220 |
| 228 // Initialize BeginFrame emulation | 221 // Initialize BeginFrame emulation |
| (...skipping 180 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 409 EXPECT_EQ(1, software_output_device->ensure_backbuffer_count()); | 402 EXPECT_EQ(1, software_output_device->ensure_backbuffer_count()); |
| 410 EXPECT_EQ(0, software_output_device->discard_backbuffer_count()); | 403 EXPECT_EQ(0, software_output_device->discard_backbuffer_count()); |
| 411 output_surface.DiscardBackbuffer(); | 404 output_surface.DiscardBackbuffer(); |
| 412 | 405 |
| 413 EXPECT_EQ(1, software_output_device->ensure_backbuffer_count()); | 406 EXPECT_EQ(1, software_output_device->ensure_backbuffer_count()); |
| 414 EXPECT_EQ(1, software_output_device->discard_backbuffer_count()); | 407 EXPECT_EQ(1, software_output_device->discard_backbuffer_count()); |
| 415 } | 408 } |
| 416 | 409 |
| 417 } // namespace | 410 } // namespace |
| 418 } // namespace cc | 411 } // namespace cc |
| OLD | NEW |