| 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 "content/browser/compositor/browser_compositor_output_surface_proxy.h" | 7 #include "content/browser/compositor/browser_compositor_output_surface_proxy.h" |
| 8 #include "content/browser/compositor/software_browser_compositor_output_surface.
h" | 8 #include "content/browser/compositor/software_browser_compositor_output_surface.
h" |
| 9 #include "testing/gtest/include/gtest/gtest.h" | 9 #include "testing/gtest/include/gtest/gtest.h" |
| 10 #include "ui/compositor/compositor.h" | 10 #include "ui/compositor/compositor.h" |
| 11 #include "ui/compositor/test/context_factories_for_test.h" | 11 #include "ui/compositor/test/context_factories_for_test.h" |
| 12 #include "ui/gfx/vsync_provider.h" | 12 #include "ui/gfx/vsync_provider.h" |
| 13 | 13 |
| 14 namespace { | 14 namespace { |
| 15 | 15 |
| 16 class FakeVSyncProvider : public gfx::VSyncProvider { | 16 class FakeVSyncProvider : public gfx::VSyncProvider { |
| 17 public: | 17 public: |
| 18 FakeVSyncProvider() : call_count_(0) {} | 18 FakeVSyncProvider() : call_count_(0) {} |
| 19 virtual ~FakeVSyncProvider() {} | 19 virtual ~FakeVSyncProvider() {} |
| 20 | 20 |
| 21 virtual void GetVSyncParameters(const UpdateVSyncCallback& callback) | 21 virtual void GetVSyncParameters(const UpdateVSyncCallback& callback) |
| 22 OVERRIDE { | 22 override { |
| 23 callback.Run(timebase_, interval_); | 23 callback.Run(timebase_, interval_); |
| 24 call_count_++; | 24 call_count_++; |
| 25 } | 25 } |
| 26 | 26 |
| 27 int call_count() const { return call_count_; } | 27 int call_count() const { return call_count_; } |
| 28 | 28 |
| 29 void set_timebase(base::TimeTicks timebase) { timebase_ = timebase; } | 29 void set_timebase(base::TimeTicks timebase) { timebase_ = timebase; } |
| 30 void set_interval(base::TimeDelta interval) { interval_ = interval; } | 30 void set_interval(base::TimeDelta interval) { interval_ = interval; } |
| 31 | 31 |
| 32 private: | 32 private: |
| 33 base::TimeTicks timebase_; | 33 base::TimeTicks timebase_; |
| 34 base::TimeDelta interval_; | 34 base::TimeDelta interval_; |
| 35 | 35 |
| 36 int call_count_; | 36 int call_count_; |
| 37 | 37 |
| 38 DISALLOW_COPY_AND_ASSIGN(FakeVSyncProvider); | 38 DISALLOW_COPY_AND_ASSIGN(FakeVSyncProvider); |
| 39 }; | 39 }; |
| 40 | 40 |
| 41 class FakeSoftwareOutputDevice : public cc::SoftwareOutputDevice { | 41 class FakeSoftwareOutputDevice : public cc::SoftwareOutputDevice { |
| 42 public: | 42 public: |
| 43 FakeSoftwareOutputDevice() : vsync_provider_(new FakeVSyncProvider()) {} | 43 FakeSoftwareOutputDevice() : vsync_provider_(new FakeVSyncProvider()) {} |
| 44 virtual ~FakeSoftwareOutputDevice() {} | 44 virtual ~FakeSoftwareOutputDevice() {} |
| 45 | 45 |
| 46 virtual gfx::VSyncProvider* GetVSyncProvider() OVERRIDE { | 46 virtual gfx::VSyncProvider* GetVSyncProvider() override { |
| 47 return vsync_provider_.get(); | 47 return vsync_provider_.get(); |
| 48 } | 48 } |
| 49 | 49 |
| 50 private: | 50 private: |
| 51 scoped_ptr<gfx::VSyncProvider> vsync_provider_; | 51 scoped_ptr<gfx::VSyncProvider> vsync_provider_; |
| 52 | 52 |
| 53 DISALLOW_COPY_AND_ASSIGN(FakeSoftwareOutputDevice); | 53 DISALLOW_COPY_AND_ASSIGN(FakeSoftwareOutputDevice); |
| 54 }; | 54 }; |
| 55 | 55 |
| 56 } // namespace | 56 } // namespace |
| 57 | 57 |
| 58 class SoftwareBrowserCompositorOutputSurfaceTest : public testing::Test { | 58 class SoftwareBrowserCompositorOutputSurfaceTest : public testing::Test { |
| 59 public: | 59 public: |
| 60 SoftwareBrowserCompositorOutputSurfaceTest(); | 60 SoftwareBrowserCompositorOutputSurfaceTest(); |
| 61 virtual ~SoftwareBrowserCompositorOutputSurfaceTest(); | 61 virtual ~SoftwareBrowserCompositorOutputSurfaceTest(); |
| 62 | 62 |
| 63 virtual void SetUp() OVERRIDE; | 63 virtual void SetUp() override; |
| 64 virtual void TearDown() OVERRIDE; | 64 virtual void TearDown() override; |
| 65 | 65 |
| 66 scoped_ptr<content::BrowserCompositorOutputSurface> CreateSurface( | 66 scoped_ptr<content::BrowserCompositorOutputSurface> CreateSurface( |
| 67 scoped_ptr<cc::SoftwareOutputDevice> device); | 67 scoped_ptr<cc::SoftwareOutputDevice> device); |
| 68 | 68 |
| 69 protected: | 69 protected: |
| 70 scoped_ptr<content::BrowserCompositorOutputSurface> output_surface_; | 70 scoped_ptr<content::BrowserCompositorOutputSurface> output_surface_; |
| 71 | 71 |
| 72 scoped_ptr<base::MessageLoop> message_loop_; | 72 scoped_ptr<base::MessageLoop> message_loop_; |
| 73 scoped_ptr<ui::Compositor> compositor_; | 73 scoped_ptr<ui::Compositor> compositor_; |
| 74 | 74 |
| (...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 140 | 140 |
| 141 FakeVSyncProvider* vsync_provider = static_cast<FakeVSyncProvider*>( | 141 FakeVSyncProvider* vsync_provider = static_cast<FakeVSyncProvider*>( |
| 142 output_surface_->software_device()->GetVSyncProvider()); | 142 output_surface_->software_device()->GetVSyncProvider()); |
| 143 EXPECT_EQ(0, vsync_provider->call_count()); | 143 EXPECT_EQ(0, vsync_provider->call_count()); |
| 144 | 144 |
| 145 cc::CompositorFrame frame; | 145 cc::CompositorFrame frame; |
| 146 output_surface_->SwapBuffers(&frame); | 146 output_surface_->SwapBuffers(&frame); |
| 147 | 147 |
| 148 EXPECT_EQ(1, vsync_provider->call_count()); | 148 EXPECT_EQ(1, vsync_provider->call_count()); |
| 149 } | 149 } |
| OLD | NEW |