Chromium Code Reviews| Index: cc/layer_tree_host_unittest.cc |
| diff --git a/cc/layer_tree_host_unittest.cc b/cc/layer_tree_host_unittest.cc |
| index 6dd780da4d47b5c4290a3438b32fc477e30d2ea9..85c985849f5f4cd6bea74a12abc21b11b1814394 100644 |
| --- a/cc/layer_tree_host_unittest.cc |
| +++ b/cc/layer_tree_host_unittest.cc |
| @@ -16,6 +16,7 @@ |
| #include "cc/prioritized_resource.h" |
| #include "cc/prioritized_resource_manager.h" |
| #include "cc/resource_update_queue.h" |
| +#include "cc/scrollbar_layer.h" |
| #include "cc/single_thread_proxy.h" |
| #include "cc/test/fake_content_layer.h" |
| #include "cc/test/fake_content_layer_client.h" |
| @@ -2194,5 +2195,117 @@ private: |
| SINGLE_AND_MULTI_THREAD_TEST_F(LayerTreeHostTestShutdownWithOnlySomeResourcesEvicted) |
| +class LayerTreeHostTestPinchZoomScrollbarCreation : public LayerTreeHostTest { |
| +public: |
| + LayerTreeHostTestPinchZoomScrollbarCreation() |
| + : m_rootLayer(ContentLayer::create(&m_client)) |
| + { |
| + m_settings.usePinchZoomScrollbars = true; |
|
enne (OOO)
2013/03/11 21:08:24
This is inconsistently formatted with the rest of
wjmaclean
2013/03/12 16:13:07
Done.
|
| + } |
| + |
| + virtual void beginTest() OVERRIDE |
| + { |
| + m_rootLayer->setIsDrawable(true); |
| + m_rootLayer->setBounds(gfx::Size(100, 100)); |
| + m_layerTreeHost->setRootLayer(m_rootLayer); |
| + postSetNeedsCommitToMainThread(); |
| + } |
| + |
| + virtual void didCommit() OVERRIDE |
| + { |
| + // We always expect two pinch-zoom scrollbar layers. |
| + ASSERT_TRUE(2 == m_rootLayer->children().size()); |
| + |
| + // Pinch-zoom scrollbar layers always have invalid scrollLayerIds. |
| + ScrollbarLayer* layer1 = m_rootLayer->children()[0]->toScrollbarLayer(); |
| + ASSERT_TRUE(layer1); |
| + EXPECT_EQ(Layer::s_invalidLayerId, layer1->scrollLayerId()); |
| + EXPECT_EQ(0, layer1->opacity()); |
| + EXPECT_TRUE(layer1->drawsContent()); |
| + |
| + ScrollbarLayer* layer2 = m_rootLayer->children()[1]->toScrollbarLayer(); |
| + ASSERT_TRUE(layer2); |
| + EXPECT_EQ(Layer::s_invalidLayerId, layer2->scrollLayerId()); |
| + EXPECT_EQ(0, layer2->opacity()); |
| + EXPECT_TRUE(layer2->drawsContent()); |
| + |
| + endTest(); |
| + } |
| + |
| + virtual void afterTest() OVERRIDE |
| + { |
| + } |
| + |
| +private: |
| + FakeContentLayerClient m_client; |
| + scoped_refptr<ContentLayer> m_rootLayer; |
| +}; |
| + |
| +SINGLE_AND_MULTI_THREAD_TEST_F(LayerTreeHostTestPinchZoomScrollbarCreation) |
| + |
| +class LayerTreeHostTestPinchZoomScrollbarResize : public LayerTreeHostTest { |
| +public: |
| + LayerTreeHostTestPinchZoomScrollbarResize() |
| + : m_rootLayer(ContentLayer::create(&m_client)) |
| + , m_numCommits(0) |
| + { |
| + m_settings.usePinchZoomScrollbars = true; |
| + } |
| + |
| + virtual void beginTest() OVERRIDE |
| + { |
| + m_rootLayer->setIsDrawable(true); |
| + m_rootLayer->setBounds(gfx::Size(100, 100)); |
| + m_layerTreeHost->setRootLayer(m_rootLayer); |
| + m_layerTreeHost->setViewportSize(gfx::Size(100, 100), |
| + gfx::Size(100, 100)); |
| + postSetNeedsCommitToMainThread(); |
| + } |
| + |
| + virtual void didCommit() OVERRIDE |
| + { |
| + m_numCommits++; |
| + |
| + ScrollbarLayer* layer1 = m_rootLayer->children()[0]->toScrollbarLayer(); |
| + ASSERT_TRUE(layer1); |
| + ScrollbarLayer* layer2 = m_rootLayer->children()[1]->toScrollbarLayer(); |
| + ASSERT_TRUE(layer2); |
| + |
| + // Get scrollbar thickness from horizontal scrollbar's height. |
| + int thickness = layer1->bounds().height(); |
| + |
| + if (!layer1->orientation() == WebKit::WebScrollbar::Horizontal) |
| + std::swap(layer1, layer2); |
| + |
| + gfx::Size viewportSize = m_layerTreeHost->layoutViewportSize(); |
| + EXPECT_EQ(viewportSize.width() - thickness, layer1->bounds().width()); |
| + EXPECT_EQ(viewportSize.height() - thickness, layer2->bounds().height()); |
| + |
| + switch (m_numCommits) { |
| + case 1: |
| + // Resizing the viewport should also resize the pinch-zoom scrollbars. |
| + m_layerTreeHost->setViewportSize(gfx::Size(120, 150), |
| + gfx::Size(120, 150)); |
| + break; |
| + case 2: |
| + endTest(); |
| + break; |
| + default: |
| + NOTREACHED(); |
| + } |
| + } |
| + |
| + virtual void afterTest() OVERRIDE |
| + { |
| + } |
| + |
| +private: |
| + FakeContentLayerClient m_client; |
| + scoped_refptr<ContentLayer> m_rootLayer; |
| + int m_numCommits; |
| +}; |
| + |
| +SINGLE_AND_MULTI_THREAD_TEST_F(LayerTreeHostTestPinchZoomScrollbarResize) |
| + |
| } // namespace |
| } // namespace cc |