| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 "content/browser/compositor/software_browser_compositor_output_surface.
h" |
| 6 |
| 7 #include <utility> |
| 8 |
| 5 #include "base/macros.h" | 9 #include "base/macros.h" |
| 6 #include "base/thread_task_runner_handle.h" | 10 #include "base/thread_task_runner_handle.h" |
| 7 #include "cc/output/compositor_frame.h" | 11 #include "cc/output/compositor_frame.h" |
| 8 #include "cc/test/fake_output_surface_client.h" | 12 #include "cc/test/fake_output_surface_client.h" |
| 9 #include "content/browser/compositor/software_browser_compositor_output_surface.
h" | |
| 10 #include "testing/gtest/include/gtest/gtest.h" | 13 #include "testing/gtest/include/gtest/gtest.h" |
| 11 #include "ui/compositor/compositor.h" | 14 #include "ui/compositor/compositor.h" |
| 12 #include "ui/compositor/test/context_factories_for_test.h" | 15 #include "ui/compositor/test/context_factories_for_test.h" |
| 13 #include "ui/gfx/vsync_provider.h" | 16 #include "ui/gfx/vsync_provider.h" |
| 14 | 17 |
| 15 namespace { | 18 namespace { |
| 16 | 19 |
| 17 class FakeVSyncProvider : public gfx::VSyncProvider { | 20 class FakeVSyncProvider : public gfx::VSyncProvider { |
| 18 public: | 21 public: |
| 19 FakeVSyncProvider() : call_count_(0) {} | 22 FakeVSyncProvider() : call_count_(0) {} |
| (...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 99 output_surface_.reset(); | 102 output_surface_.reset(); |
| 100 compositor_.reset(); | 103 compositor_.reset(); |
| 101 ui::TerminateContextFactoryForTests(); | 104 ui::TerminateContextFactoryForTests(); |
| 102 } | 105 } |
| 103 | 106 |
| 104 scoped_ptr<content::BrowserCompositorOutputSurface> | 107 scoped_ptr<content::BrowserCompositorOutputSurface> |
| 105 SoftwareBrowserCompositorOutputSurfaceTest::CreateSurface( | 108 SoftwareBrowserCompositorOutputSurfaceTest::CreateSurface( |
| 106 scoped_ptr<cc::SoftwareOutputDevice> device) { | 109 scoped_ptr<cc::SoftwareOutputDevice> device) { |
| 107 return scoped_ptr<content::BrowserCompositorOutputSurface>( | 110 return scoped_ptr<content::BrowserCompositorOutputSurface>( |
| 108 new content::SoftwareBrowserCompositorOutputSurface( | 111 new content::SoftwareBrowserCompositorOutputSurface( |
| 109 device.Pass(), | 112 std::move(device), compositor_->vsync_manager())); |
| 110 compositor_->vsync_manager())); | |
| 111 } | 113 } |
| 112 | 114 |
| 113 TEST_F(SoftwareBrowserCompositorOutputSurfaceTest, NoVSyncProvider) { | 115 TEST_F(SoftwareBrowserCompositorOutputSurfaceTest, NoVSyncProvider) { |
| 114 cc::FakeOutputSurfaceClient output_surface_client; | 116 cc::FakeOutputSurfaceClient output_surface_client; |
| 115 scoped_ptr<cc::SoftwareOutputDevice> software_device( | 117 scoped_ptr<cc::SoftwareOutputDevice> software_device( |
| 116 new cc::SoftwareOutputDevice()); | 118 new cc::SoftwareOutputDevice()); |
| 117 output_surface_ = CreateSurface(software_device.Pass()); | 119 output_surface_ = CreateSurface(std::move(software_device)); |
| 118 CHECK(output_surface_->BindToClient(&output_surface_client)); | 120 CHECK(output_surface_->BindToClient(&output_surface_client)); |
| 119 | 121 |
| 120 cc::CompositorFrame frame; | 122 cc::CompositorFrame frame; |
| 121 output_surface_->SwapBuffers(&frame); | 123 output_surface_->SwapBuffers(&frame); |
| 122 | 124 |
| 123 EXPECT_EQ(1, output_surface_client.swap_count()); | 125 EXPECT_EQ(1, output_surface_client.swap_count()); |
| 124 EXPECT_EQ(NULL, output_surface_->software_device()->GetVSyncProvider()); | 126 EXPECT_EQ(NULL, output_surface_->software_device()->GetVSyncProvider()); |
| 125 } | 127 } |
| 126 | 128 |
| 127 TEST_F(SoftwareBrowserCompositorOutputSurfaceTest, VSyncProviderUpdates) { | 129 TEST_F(SoftwareBrowserCompositorOutputSurfaceTest, VSyncProviderUpdates) { |
| 128 cc::FakeOutputSurfaceClient output_surface_client; | 130 cc::FakeOutputSurfaceClient output_surface_client; |
| 129 scoped_ptr<cc::SoftwareOutputDevice> software_device( | 131 scoped_ptr<cc::SoftwareOutputDevice> software_device( |
| 130 new FakeSoftwareOutputDevice()); | 132 new FakeSoftwareOutputDevice()); |
| 131 output_surface_ = CreateSurface(software_device.Pass()); | 133 output_surface_ = CreateSurface(std::move(software_device)); |
| 132 CHECK(output_surface_->BindToClient(&output_surface_client)); | 134 CHECK(output_surface_->BindToClient(&output_surface_client)); |
| 133 | 135 |
| 134 FakeVSyncProvider* vsync_provider = static_cast<FakeVSyncProvider*>( | 136 FakeVSyncProvider* vsync_provider = static_cast<FakeVSyncProvider*>( |
| 135 output_surface_->software_device()->GetVSyncProvider()); | 137 output_surface_->software_device()->GetVSyncProvider()); |
| 136 EXPECT_EQ(0, vsync_provider->call_count()); | 138 EXPECT_EQ(0, vsync_provider->call_count()); |
| 137 | 139 |
| 138 cc::CompositorFrame frame; | 140 cc::CompositorFrame frame; |
| 139 output_surface_->SwapBuffers(&frame); | 141 output_surface_->SwapBuffers(&frame); |
| 140 | 142 |
| 141 EXPECT_EQ(1, output_surface_client.swap_count()); | 143 EXPECT_EQ(1, output_surface_client.swap_count()); |
| 142 EXPECT_EQ(1, vsync_provider->call_count()); | 144 EXPECT_EQ(1, vsync_provider->call_count()); |
| 143 } | 145 } |
| OLD | NEW |