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 "cc/output/delegating_renderer.h" | 5 #include "cc/output/delegating_renderer.h" |
6 #include "cc/output/gl_renderer.h" | 6 #include "cc/output/gl_renderer.h" |
7 #include "cc/output/output_surface.h" | 7 #include "cc/output/output_surface.h" |
8 #include "cc/test/fake_output_surface_client.h" | 8 #include "cc/test/fake_output_surface_client.h" |
9 #include "cc/test/fake_renderer_client.h" | 9 #include "cc/test/fake_renderer_client.h" |
10 #include "cc/test/test_context_provider.h" | 10 #include "cc/test/test_context_provider.h" |
11 #include "cc/test/test_web_graphics_context_3d.h" | 11 #include "cc/test/test_web_graphics_context_3d.h" |
12 #include "testing/gmock/include/gmock/gmock.h" | 12 #include "testing/gmock/include/gmock/gmock.h" |
13 #include "testing/gtest/include/gtest/gtest.h" | 13 #include "testing/gtest/include/gtest/gtest.h" |
14 | 14 |
15 namespace cc { | 15 namespace cc { |
16 namespace { | 16 namespace { |
17 | 17 |
| 18 class TestOutputSurface : public OutputSurface { |
| 19 public: |
| 20 explicit TestOutputSurface( |
| 21 const scoped_refptr<ContextProvider>& context_provider); |
| 22 virtual ~TestOutputSurface() override; |
| 23 |
| 24 // OutputSurface implementation |
| 25 virtual void SwapBuffers(CompositorFrame* frame) override; |
| 26 }; |
| 27 |
| 28 TestOutputSurface::TestOutputSurface( |
| 29 const scoped_refptr<ContextProvider>& context_provider) |
| 30 : OutputSurface(context_provider) { |
| 31 } |
| 32 |
| 33 TestOutputSurface::~TestOutputSurface() { |
| 34 } |
| 35 |
| 36 void TestOutputSurface::SwapBuffers(CompositorFrame* frame) { |
| 37 client_->DidSwapBuffers(); |
| 38 client_->DidSwapBuffersComplete(); |
| 39 } |
| 40 |
18 class MockContextProvider : public TestContextProvider { | 41 class MockContextProvider : public TestContextProvider { |
19 public: | 42 public: |
20 explicit MockContextProvider(scoped_ptr<TestWebGraphicsContext3D> context) | 43 explicit MockContextProvider(scoped_ptr<TestWebGraphicsContext3D> context) |
21 : TestContextProvider(context.Pass()) {} | 44 : TestContextProvider(context.Pass()) {} |
22 MOCK_METHOD0(DeleteCachedResources, void()); | 45 MOCK_METHOD0(DeleteCachedResources, void()); |
23 | 46 |
24 protected: | 47 protected: |
25 ~MockContextProvider() {} | 48 ~MockContextProvider() {} |
26 }; | 49 }; |
27 | 50 |
(...skipping 22 matching lines...) Expand all Loading... |
50 return GLRenderer::Create( | 73 return GLRenderer::Create( |
51 client, settings, output_surface, resource_provider, NULL, 0); | 74 client, settings, output_surface, resource_provider, NULL, 0); |
52 } | 75 } |
53 | 76 |
54 template <typename T> | 77 template <typename T> |
55 class RendererTest : public ::testing::Test { | 78 class RendererTest : public ::testing::Test { |
56 protected: | 79 protected: |
57 virtual void SetUp() { | 80 virtual void SetUp() { |
58 context_provider_ = | 81 context_provider_ = |
59 new MockContextProvider(TestWebGraphicsContext3D::Create()); | 82 new MockContextProvider(TestWebGraphicsContext3D::Create()); |
60 output_surface_.reset(new OutputSurface(context_provider_)); | 83 output_surface_.reset(new TestOutputSurface(context_provider_)); |
61 output_surface_->BindToClient(&output_surface_client_); | 84 output_surface_->BindToClient(&output_surface_client_); |
62 resource_provider_ = ResourceProvider::Create( | 85 resource_provider_ = ResourceProvider::Create( |
63 output_surface_.get(), NULL, NULL, 0, false, 1, false); | 86 output_surface_.get(), NULL, NULL, 0, false, 1, false); |
64 renderer_ = CreateRenderer<T>(&renderer_client_, | 87 renderer_ = CreateRenderer<T>(&renderer_client_, |
65 &tree_settings_, | 88 &tree_settings_, |
66 output_surface_.get(), | 89 output_surface_.get(), |
67 resource_provider_.get()); | 90 resource_provider_.get()); |
68 } | 91 } |
69 | 92 |
70 FakeRendererClient renderer_client_; | 93 FakeRendererClient renderer_client_; |
(...skipping 12 matching lines...) Expand all Loading... |
83 EXPECT_CALL(*(this->context_provider_.get()), DeleteCachedResources()) | 106 EXPECT_CALL(*(this->context_provider_.get()), DeleteCachedResources()) |
84 .Times(1); | 107 .Times(1); |
85 | 108 |
86 EXPECT_TRUE(this->renderer_->visible()); | 109 EXPECT_TRUE(this->renderer_->visible()); |
87 this->renderer_->SetVisible(false); | 110 this->renderer_->SetVisible(false); |
88 EXPECT_FALSE(this->renderer_->visible()); | 111 EXPECT_FALSE(this->renderer_->visible()); |
89 } | 112 } |
90 | 113 |
91 } // namespace | 114 } // namespace |
92 } // namespace cc | 115 } // namespace cc |
OLD | NEW |