| 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 "base/message_loop/message_loop.h" | 5 #include "base/message_loop/message_loop.h" |
| 6 #include "cc/output/compositor_frame.h" | 6 #include "cc/output/compositor_frame.h" |
| 7 #include "cc/test/fake_output_surface_client.h" |
| 7 #include "content/browser/compositor/browser_compositor_output_surface_proxy.h" | 8 #include "content/browser/compositor/browser_compositor_output_surface_proxy.h" |
| 8 #include "content/browser/compositor/software_browser_compositor_output_surface.
h" | 9 #include "content/browser/compositor/software_browser_compositor_output_surface.
h" |
| 9 #include "testing/gtest/include/gtest/gtest.h" | 10 #include "testing/gtest/include/gtest/gtest.h" |
| 10 #include "ui/compositor/compositor.h" | 11 #include "ui/compositor/compositor.h" |
| 11 #include "ui/compositor/test/context_factories_for_test.h" | 12 #include "ui/compositor/test/context_factories_for_test.h" |
| 12 #include "ui/gfx/vsync_provider.h" | 13 #include "ui/gfx/vsync_provider.h" |
| 13 | 14 |
| 14 namespace { | 15 namespace { |
| 15 | 16 |
| 16 class FakeVSyncProvider : public gfx::VSyncProvider { | 17 class FakeVSyncProvider : public gfx::VSyncProvider { |
| (...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 116 return scoped_ptr<content::BrowserCompositorOutputSurface>( | 117 return scoped_ptr<content::BrowserCompositorOutputSurface>( |
| 117 new content::SoftwareBrowserCompositorOutputSurface( | 118 new content::SoftwareBrowserCompositorOutputSurface( |
| 118 surface_proxy_, | 119 surface_proxy_, |
| 119 device.Pass(), | 120 device.Pass(), |
| 120 1, | 121 1, |
| 121 &surface_map_, | 122 &surface_map_, |
| 122 compositor_->vsync_manager())); | 123 compositor_->vsync_manager())); |
| 123 } | 124 } |
| 124 | 125 |
| 125 TEST_F(SoftwareBrowserCompositorOutputSurfaceTest, NoVSyncProvider) { | 126 TEST_F(SoftwareBrowserCompositorOutputSurfaceTest, NoVSyncProvider) { |
| 127 cc::FakeOutputSurfaceClient output_surface_client; |
| 126 scoped_ptr<cc::SoftwareOutputDevice> software_device( | 128 scoped_ptr<cc::SoftwareOutputDevice> software_device( |
| 127 new cc::SoftwareOutputDevice()); | 129 new cc::SoftwareOutputDevice()); |
| 128 output_surface_ = CreateSurface(software_device.Pass()); | 130 output_surface_ = CreateSurface(software_device.Pass()); |
| 131 CHECK(output_surface_->BindToClient(&output_surface_client)); |
| 129 | 132 |
| 130 cc::CompositorFrame frame; | 133 cc::CompositorFrame frame; |
| 131 output_surface_->SwapBuffers(&frame); | 134 output_surface_->SwapBuffers(&frame); |
| 132 | 135 |
| 136 EXPECT_EQ(1, output_surface_client.swap_count()); |
| 133 EXPECT_EQ(NULL, output_surface_->software_device()->GetVSyncProvider()); | 137 EXPECT_EQ(NULL, output_surface_->software_device()->GetVSyncProvider()); |
| 134 } | 138 } |
| 135 | 139 |
| 136 TEST_F(SoftwareBrowserCompositorOutputSurfaceTest, VSyncProviderUpdates) { | 140 TEST_F(SoftwareBrowserCompositorOutputSurfaceTest, VSyncProviderUpdates) { |
| 141 cc::FakeOutputSurfaceClient output_surface_client; |
| 137 scoped_ptr<cc::SoftwareOutputDevice> software_device( | 142 scoped_ptr<cc::SoftwareOutputDevice> software_device( |
| 138 new FakeSoftwareOutputDevice()); | 143 new FakeSoftwareOutputDevice()); |
| 139 output_surface_ = CreateSurface(software_device.Pass()); | 144 output_surface_ = CreateSurface(software_device.Pass()); |
| 145 CHECK(output_surface_->BindToClient(&output_surface_client)); |
| 140 | 146 |
| 141 FakeVSyncProvider* vsync_provider = static_cast<FakeVSyncProvider*>( | 147 FakeVSyncProvider* vsync_provider = static_cast<FakeVSyncProvider*>( |
| 142 output_surface_->software_device()->GetVSyncProvider()); | 148 output_surface_->software_device()->GetVSyncProvider()); |
| 143 EXPECT_EQ(0, vsync_provider->call_count()); | 149 EXPECT_EQ(0, vsync_provider->call_count()); |
| 144 | 150 |
| 145 cc::CompositorFrame frame; | 151 cc::CompositorFrame frame; |
| 146 output_surface_->SwapBuffers(&frame); | 152 output_surface_->SwapBuffers(&frame); |
| 147 | 153 |
| 154 EXPECT_EQ(1, output_surface_client.swap_count()); |
| 148 EXPECT_EQ(1, vsync_provider->call_count()); | 155 EXPECT_EQ(1, vsync_provider->call_count()); |
| 149 } | 156 } |
| OLD | NEW |