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 "cc/test/fake_output_surface_client.h" |
8 #include "content/browser/compositor/browser_compositor_output_surface_proxy.h" | 8 #include "content/browser/compositor/browser_compositor_output_surface_proxy.h" |
9 #include "content/browser/compositor/software_browser_compositor_output_surface.
h" | 9 #include "content/browser/compositor/software_browser_compositor_output_surface.
h" |
10 #include "testing/gtest/include/gtest/gtest.h" | 10 #include "testing/gtest/include/gtest/gtest.h" |
11 #include "ui/compositor/compositor.h" | 11 #include "ui/compositor/compositor.h" |
12 #include "ui/compositor/test/context_factories_for_test.h" | 12 #include "ui/compositor/test/context_factories_for_test.h" |
13 #include "ui/gfx/vsync_provider.h" | 13 #include "ui/gfx/vsync_provider.h" |
14 | 14 |
15 namespace { | 15 namespace { |
16 | 16 |
17 class FakeVSyncProvider : public gfx::VSyncProvider { | 17 class FakeVSyncProvider : public gfx::VSyncProvider { |
18 public: | 18 public: |
19 FakeVSyncProvider() : call_count_(0) {} | 19 FakeVSyncProvider() : call_count_(0) {} |
20 virtual ~FakeVSyncProvider() {} | 20 ~FakeVSyncProvider() override {} |
21 | 21 |
22 virtual void GetVSyncParameters(const UpdateVSyncCallback& callback) | 22 void GetVSyncParameters(const UpdateVSyncCallback& callback) override { |
23 override { | |
24 callback.Run(timebase_, interval_); | 23 callback.Run(timebase_, interval_); |
25 call_count_++; | 24 call_count_++; |
26 } | 25 } |
27 | 26 |
28 int call_count() const { return call_count_; } | 27 int call_count() const { return call_count_; } |
29 | 28 |
30 void set_timebase(base::TimeTicks timebase) { timebase_ = timebase; } | 29 void set_timebase(base::TimeTicks timebase) { timebase_ = timebase; } |
31 void set_interval(base::TimeDelta interval) { interval_ = interval; } | 30 void set_interval(base::TimeDelta interval) { interval_ = interval; } |
32 | 31 |
33 private: | 32 private: |
34 base::TimeTicks timebase_; | 33 base::TimeTicks timebase_; |
35 base::TimeDelta interval_; | 34 base::TimeDelta interval_; |
36 | 35 |
37 int call_count_; | 36 int call_count_; |
38 | 37 |
39 DISALLOW_COPY_AND_ASSIGN(FakeVSyncProvider); | 38 DISALLOW_COPY_AND_ASSIGN(FakeVSyncProvider); |
40 }; | 39 }; |
41 | 40 |
42 class FakeSoftwareOutputDevice : public cc::SoftwareOutputDevice { | 41 class FakeSoftwareOutputDevice : public cc::SoftwareOutputDevice { |
43 public: | 42 public: |
44 FakeSoftwareOutputDevice() : vsync_provider_(new FakeVSyncProvider()) {} | 43 FakeSoftwareOutputDevice() : vsync_provider_(new FakeVSyncProvider()) {} |
45 virtual ~FakeSoftwareOutputDevice() {} | 44 ~FakeSoftwareOutputDevice() override {} |
46 | 45 |
47 virtual gfx::VSyncProvider* GetVSyncProvider() override { | 46 gfx::VSyncProvider* GetVSyncProvider() override { |
48 return vsync_provider_.get(); | 47 return vsync_provider_.get(); |
49 } | 48 } |
50 | 49 |
51 private: | 50 private: |
52 scoped_ptr<gfx::VSyncProvider> vsync_provider_; | 51 scoped_ptr<gfx::VSyncProvider> vsync_provider_; |
53 | 52 |
54 DISALLOW_COPY_AND_ASSIGN(FakeSoftwareOutputDevice); | 53 DISALLOW_COPY_AND_ASSIGN(FakeSoftwareOutputDevice); |
55 }; | 54 }; |
56 | 55 |
57 } // namespace | 56 } // namespace |
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
147 FakeVSyncProvider* vsync_provider = static_cast<FakeVSyncProvider*>( | 146 FakeVSyncProvider* vsync_provider = static_cast<FakeVSyncProvider*>( |
148 output_surface_->software_device()->GetVSyncProvider()); | 147 output_surface_->software_device()->GetVSyncProvider()); |
149 EXPECT_EQ(0, vsync_provider->call_count()); | 148 EXPECT_EQ(0, vsync_provider->call_count()); |
150 | 149 |
151 cc::CompositorFrame frame; | 150 cc::CompositorFrame frame; |
152 output_surface_->SwapBuffers(&frame); | 151 output_surface_->SwapBuffers(&frame); |
153 | 152 |
154 EXPECT_EQ(1, output_surface_client.swap_count()); | 153 EXPECT_EQ(1, output_surface_client.swap_count()); |
155 EXPECT_EQ(1, vsync_provider->call_count()); | 154 EXPECT_EQ(1, vsync_provider->call_count()); |
156 } | 155 } |
OLD | NEW |