| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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 "platform/graphics/CompositorMutableState.h" | 5 #include "platform/graphics/CompositorMutableState.h" |
| 6 | 6 |
| 7 #include "base/message_loop/message_loop.h" | 7 #include "base/message_loop/message_loop.h" |
| 8 #include "cc/test/fake_compositor_frame_sink.h" |
| 8 #include "cc/test/fake_impl_task_runner_provider.h" | 9 #include "cc/test/fake_impl_task_runner_provider.h" |
| 9 #include "cc/test/fake_layer_tree_host_impl.h" | 10 #include "cc/test/fake_layer_tree_host_impl.h" |
| 10 #include "cc/test/fake_output_surface.h" | |
| 11 #include "cc/test/test_shared_bitmap_manager.h" | 11 #include "cc/test/test_shared_bitmap_manager.h" |
| 12 #include "cc/test/test_task_graph_runner.h" | 12 #include "cc/test/test_task_graph_runner.h" |
| 13 #include "cc/trees/layer_tree_host_impl.h" | 13 #include "cc/trees/layer_tree_host_impl.h" |
| 14 #include "cc/trees/layer_tree_impl.h" | 14 #include "cc/trees/layer_tree_impl.h" |
| 15 #include "platform/graphics/CompositorElementId.h" | 15 #include "platform/graphics/CompositorElementId.h" |
| 16 #include "platform/graphics/CompositorMutableProperties.h" | 16 #include "platform/graphics/CompositorMutableProperties.h" |
| 17 #include "platform/graphics/CompositorMutableStateProvider.h" | 17 #include "platform/graphics/CompositorMutableStateProvider.h" |
| 18 #include "platform/graphics/CompositorMutation.h" | 18 #include "platform/graphics/CompositorMutation.h" |
| 19 #include "testing/gtest/include/gtest/gtest.h" | 19 #include "testing/gtest/include/gtest/gtest.h" |
| 20 #include <memory> | 20 #include <memory> |
| 21 | 21 |
| 22 namespace blink { | 22 namespace blink { |
| 23 | 23 |
| 24 using cc::FakeImplTaskRunnerProvider; | 24 using cc::FakeImplTaskRunnerProvider; |
| 25 using cc::FakeLayerTreeHostImpl; | 25 using cc::FakeLayerTreeHostImpl; |
| 26 using cc::FakeOutputSurface; | 26 using cc::FakeCompositorFrameSink; |
| 27 using cc::LayerImpl; | 27 using cc::LayerImpl; |
| 28 using cc::LayerTreeSettings; | 28 using cc::LayerTreeSettings; |
| 29 using cc::OutputSurface; | |
| 30 using cc::TestTaskGraphRunner; | 29 using cc::TestTaskGraphRunner; |
| 31 using cc::TestSharedBitmapManager; | 30 using cc::TestSharedBitmapManager; |
| 32 | 31 |
| 33 class CompositorMutableStateTest : public testing::Test { | 32 class CompositorMutableStateTest : public testing::Test { |
| 34 public: | 33 public: |
| 35 CompositorMutableStateTest() | 34 CompositorMutableStateTest() |
| 36 : m_outputSurface(FakeOutputSurface::CreateDelegating3d()) | 35 : m_compositorFrameSink(FakeCompositorFrameSink::Create3d()) |
| 37 { | 36 { |
| 38 LayerTreeSettings settings; | 37 LayerTreeSettings settings; |
| 39 settings.layer_transforms_should_scale_layer_contents = true; | 38 settings.layer_transforms_should_scale_layer_contents = true; |
| 40 m_hostImpl.reset(new FakeLayerTreeHostImpl(settings, &m_taskRunnerProvid
er, &m_sharedBitmapManager, &m_taskGraphRunner)); | 39 m_hostImpl.reset(new FakeLayerTreeHostImpl(settings, &m_taskRunnerProvid
er, &m_sharedBitmapManager, &m_taskGraphRunner)); |
| 41 m_hostImpl->SetVisible(true); | 40 m_hostImpl->SetVisible(true); |
| 42 EXPECT_TRUE(m_hostImpl->InitializeRenderer(m_outputSurface.get())); | 41 EXPECT_TRUE(m_hostImpl->InitializeRenderer(m_compositorFrameSink.get()))
; |
| 43 } | 42 } |
| 44 | 43 |
| 45 void SetLayerPropertiesForTesting(LayerImpl* layer) | 44 void SetLayerPropertiesForTesting(LayerImpl* layer) |
| 46 { | 45 { |
| 47 layer->test_properties()->transform = gfx::Transform(); | 46 layer->test_properties()->transform = gfx::Transform(); |
| 48 layer->SetPosition(gfx::PointF()); | 47 layer->SetPosition(gfx::PointF()); |
| 49 layer->SetBounds(gfx::Size(100, 100)); | 48 layer->SetBounds(gfx::Size(100, 100)); |
| 50 layer->Set3dSortingContextId(0); | 49 layer->Set3dSortingContextId(0); |
| 51 layer->SetDrawsContent(true); | 50 layer->SetDrawsContent(true); |
| 52 } | 51 } |
| 53 | 52 |
| 54 FakeLayerTreeHostImpl& hostImpl() { return *m_hostImpl; } | 53 FakeLayerTreeHostImpl& hostImpl() { return *m_hostImpl; } |
| 55 | 54 |
| 56 LayerImpl* rootLayer() { return m_hostImpl->active_tree()->root_layer_for_te
sting(); } | 55 LayerImpl* rootLayer() { return m_hostImpl->active_tree()->root_layer_for_te
sting(); } |
| 57 | 56 |
| 58 private: | 57 private: |
| 59 // The cc testing machinery has fairly deep dependency on having a main | 58 // The cc testing machinery has fairly deep dependency on having a main |
| 60 // message loop (one example is the task runner provider). We construct one | 59 // message loop (one example is the task runner provider). We construct one |
| 61 // here so that it's installed in TLA and can be found by other cc classes. | 60 // here so that it's installed in TLA and can be found by other cc classes. |
| 62 base::MessageLoop m_messageLoop; | 61 base::MessageLoop m_messageLoop; |
| 63 TestSharedBitmapManager m_sharedBitmapManager; | 62 TestSharedBitmapManager m_sharedBitmapManager; |
| 64 TestTaskGraphRunner m_taskGraphRunner; | 63 TestTaskGraphRunner m_taskGraphRunner; |
| 65 FakeImplTaskRunnerProvider m_taskRunnerProvider; | 64 FakeImplTaskRunnerProvider m_taskRunnerProvider; |
| 66 std::unique_ptr<OutputSurface> m_outputSurface; | 65 std::unique_ptr<FakeCompositorFrameSink> m_compositorFrameSink; |
| 67 std::unique_ptr<FakeLayerTreeHostImpl> m_hostImpl; | 66 std::unique_ptr<FakeLayerTreeHostImpl> m_hostImpl; |
| 68 }; | 67 }; |
| 69 | 68 |
| 70 TEST_F(CompositorMutableStateTest, NoMutableState) | 69 TEST_F(CompositorMutableStateTest, NoMutableState) |
| 71 { | 70 { |
| 72 // In this test, there are no layers with either an element id or mutable | 71 // In this test, there are no layers with either an element id or mutable |
| 73 // properties. We should not be able to get any mutable state. | 72 // properties. We should not be able to get any mutable state. |
| 74 std::unique_ptr<LayerImpl> root = LayerImpl::Create(hostImpl().active_tree()
, 42); | 73 std::unique_ptr<LayerImpl> root = LayerImpl::Create(hostImpl().active_tree()
, 42); |
| 75 SetLayerPropertiesForTesting(root.get()); | 74 SetLayerPropertiesForTesting(root.get()); |
| 76 | 75 |
| (...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 142 EXPECT_TRUE(mutation.isScrollLeftMutated()); | 141 EXPECT_TRUE(mutation.isScrollLeftMutated()); |
| 143 EXPECT_TRUE(mutation.isScrollTopMutated()); | 142 EXPECT_TRUE(mutation.isScrollTopMutated()); |
| 144 | 143 |
| 145 EXPECT_EQ(0.5, mutation.opacity()); | 144 EXPECT_EQ(0.5, mutation.opacity()); |
| 146 EXPECT_EQ(zero.ToString(), gfx::Transform(mutation.transform()).ToString()); | 145 EXPECT_EQ(zero.ToString(), gfx::Transform(mutation.transform()).ToString()); |
| 147 EXPECT_EQ(1.0, mutation.scrollLeft()); | 146 EXPECT_EQ(1.0, mutation.scrollLeft()); |
| 148 EXPECT_EQ(1.0, mutation.scrollTop()); | 147 EXPECT_EQ(1.0, mutation.scrollTop()); |
| 149 } | 148 } |
| 150 | 149 |
| 151 } // namespace blink | 150 } // namespace blink |
| OLD | NEW |