Chromium Code Reviews| Index: third_party/WebKit/Source/platform/graphics/compositing/PaintArtifactCompositorTest.cpp |
| diff --git a/third_party/WebKit/Source/platform/graphics/compositing/PaintArtifactCompositorTest.cpp b/third_party/WebKit/Source/platform/graphics/compositing/PaintArtifactCompositorTest.cpp |
| index 30050b7a3ba2e398252645f7e439b6c885c8d2a7..d79cd061864eccd48000896f88ecc548ef1db793 100644 |
| --- a/third_party/WebKit/Source/platform/graphics/compositing/PaintArtifactCompositorTest.cpp |
| +++ b/third_party/WebKit/Source/platform/graphics/compositing/PaintArtifactCompositorTest.cpp |
| @@ -4,11 +4,16 @@ |
| #include "platform/graphics/compositing/PaintArtifactCompositor.h" |
| +#include "base/test/test_simple_task_runner.h" |
| +#include "base/thread_task_runner_handle.h" |
| #include "cc/layers/layer.h" |
| +#include "cc/trees/layer_tree_host.h" |
| +#include "cc/trees/layer_tree_settings.h" |
| #include "platform/RuntimeEnabledFeatures.h" |
| #include "platform/graphics/paint/PaintArtifact.h" |
| #include "platform/testing/PictureMatchers.h" |
| #include "platform/testing/TestPaintArtifact.h" |
| +#include "platform/testing/WebLayerTreeViewImplForTesting.h" |
| #include "testing/gmock/include/gmock/gmock.h" |
| #include "testing/gtest/include/gtest/gtest.h" |
| @@ -349,5 +354,65 @@ TEST_F(PaintArtifactCompositorTest, ForeignLayerPassesThrough) |
| EXPECT_EQ(translation(50, 100), layer->transform()); |
| } |
| +// Similar to the above, but for the path where we build cc property trees |
| +// directly. This will eventually supersede the above. |
| + |
| +class PaintArtifactCompositorTestWithPropertyTrees : public PaintArtifactCompositorTest { |
| +protected: |
| + PaintArtifactCompositorTestWithPropertyTrees() |
| + : m_taskRunner(new base::TestSimpleTaskRunner) |
| + , m_taskRunnerHandle(m_taskRunner) |
| + { |
| + } |
| + |
| + void SetUp() override |
| + { |
| + PaintArtifactCompositorTest::SetUp(); |
| + |
| + cc::LayerTreeSettings settings = WebLayerTreeViewImplForTesting::defaultLayerTreeSettings(); |
| + settings.use_layer_lists = true; |
| + m_webLayerTreeView = adoptPtr(new WebLayerTreeViewImplForTesting(settings)); |
| + m_webLayerTreeView->setRootLayer(*getPaintArtifactCompositor().getWebLayer()); |
| + } |
| + |
| + const cc::PropertyTrees& propertyTrees() |
| + { |
| + return *m_webLayerTreeView->layerTreeHost()->property_trees(); |
| + } |
| + |
| + void update(const PaintArtifact& artifact) |
| + { |
| + PaintArtifactCompositorTest::update(artifact); |
| + m_webLayerTreeView->layerTreeHost()->UpdateLayers(); |
|
ajuma
2016/05/06 20:33:35
Try calling LayoutAndUpdateLayers instead to see i
jbroman
2016/05/07 05:37:57
Done, thanks.
I also have to set up enough extra
|
| + } |
| + |
| +private: |
| + scoped_refptr<base::TestSimpleTaskRunner> m_taskRunner; |
| + base::ThreadTaskRunnerHandle m_taskRunnerHandle; |
| + OwnPtr<WebLayerTreeViewImplForTesting> m_webLayerTreeView; |
| +}; |
| + |
| +TEST_F(PaintArtifactCompositorTestWithPropertyTrees, EmptyPaintArtifact) |
| +{ |
| + PaintArtifact emptyArtifact; |
| + update(emptyArtifact); |
| + EXPECT_TRUE(rootLayer()->children().empty()); |
| +} |
| + |
| +TEST_F(PaintArtifactCompositorTestWithPropertyTrees, OneChunkWithAnOffset) |
| +{ |
| + TestPaintArtifact artifact; |
| + artifact.chunk(PaintChunkProperties()) |
| + .rectDrawing(FloatRect(50, -50, 100, 100), Color::white); |
| + update(artifact.build()); |
| + |
| + ASSERT_EQ(1u, rootLayer()->children().size()); |
| + const cc::Layer* child = rootLayer()->child_at(0); |
| + EXPECT_THAT(child->GetPicture(), |
| + Pointee(drawsRectangle(FloatRect(0, 0, 100, 100), Color::white))); |
| + EXPECT_EQ(translation(50, -50), child->screen_space_transform()); |
| + EXPECT_EQ(gfx::Size(100, 100), child->bounds()); |
| +} |
| + |
| } // namespace |
| } // namespace blink |