Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(215)

Unified Diff: cc/layer_tree_host_unittest.cc

Issue 11550035: Implement pinch-zoom scaling for main-frame scrollbars and pinch-zoom overlay scrollbars. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebase to fix collision with solid colour scrollbars patch. Created 7 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « cc/layer_tree_host_impl.cc ('k') | cc/layer_tree_impl.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: cc/layer_tree_host_unittest.cc
diff --git a/cc/layer_tree_host_unittest.cc b/cc/layer_tree_host_unittest.cc
index f3595a406a08557cd8b91184380ba7c2342b3896..0773cea2f21dd9c364f578bac46db59a61cb5649 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"
@@ -2195,5 +2196,177 @@ private:
SINGLE_AND_MULTI_THREAD_TEST_F(LayerTreeHostTestShutdownWithOnlySomeResourcesEvicted)
+class LayerTreeHostTestPinchZoomScrollbarCreation : public LayerTreeHostTest {
+public:
+ LayerTreeHostTestPinchZoomScrollbarCreation()
+ : m_rootLayer(ContentLayer::Create(&m_client))
+ {
+ m_settings.usePinchZoomScrollbars = true;
+ }
+
+ 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::PINCH_ZOOM_ROOT_SCROLL_LAYER_ID, layer1->scroll_layer_id());
+ EXPECT_EQ(0, layer1->opacity());
+ EXPECT_TRUE(layer1->OpacityCanAnimateOnImplThread());
+ EXPECT_TRUE(layer1->DrawsContent());
+
+ ScrollbarLayer* layer2 = m_rootLayer->children()[1]->ToScrollbarLayer();
+ ASSERT_TRUE(layer2);
+ EXPECT_EQ(Layer::PINCH_ZOOM_ROOT_SCROLL_LAYER_ID, layer2->scroll_layer_id());
+ EXPECT_EQ(0, layer2->opacity());
+ EXPECT_TRUE(layer2->OpacityCanAnimateOnImplThread());
+ 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->layout_viewport_size();
+ 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;
+ default:
+ endTest();
+ }
+ }
+
+ virtual void afterTest() OVERRIDE
+ {
+ }
+
+private:
+ FakeContentLayerClient m_client;
+ scoped_refptr<ContentLayer> m_rootLayer;
+ int m_numCommits;
+};
+
+SINGLE_AND_MULTI_THREAD_TEST_F(LayerTreeHostTestPinchZoomScrollbarResize)
+
+class LayerTreeHostTestPinchZoomScrollbarNewRootLayer : public LayerTreeHostTest {
+public:
+ LayerTreeHostTestPinchZoomScrollbarNewRootLayer()
+ : 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);
+ postSetNeedsCommitToMainThread();
+ }
+
+ virtual void didCommit() OVERRIDE
+ {
+ m_numCommits++;
+
+ // 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::PINCH_ZOOM_ROOT_SCROLL_LAYER_ID, layer1->scroll_layer_id());
+ EXPECT_EQ(0, layer1->opacity());
+ EXPECT_TRUE(layer1->DrawsContent());
+
+ ScrollbarLayer* layer2 = m_rootLayer->children()[1]->ToScrollbarLayer();
+ ASSERT_TRUE(layer2);
+ EXPECT_EQ(Layer::PINCH_ZOOM_ROOT_SCROLL_LAYER_ID, layer2->scroll_layer_id());
+ EXPECT_EQ(0, layer2->opacity());
+ EXPECT_TRUE(layer2->DrawsContent());
+
+ if (m_numCommits == 1) {
+ // Create a new root layer and attach to tree to verify the pinch
+ // zoom scrollbars get correctly re-attached.
+ m_rootLayer = ContentLayer::Create(&m_client);
+ m_rootLayer->SetIsDrawable(true);
+ m_rootLayer->SetBounds(gfx::Size(100, 100));
+ m_layerTreeHost->SetRootLayer(m_rootLayer);
+ postSetNeedsCommitToMainThread();
+ } else
+ endTest();
+ }
+
+ virtual void afterTest() OVERRIDE
+ {
+ }
+
+private:
+ FakeContentLayerClient m_client;
+ scoped_refptr<ContentLayer> m_rootLayer;
+ int m_numCommits;
+};
+
+SINGLE_AND_MULTI_THREAD_TEST_F(LayerTreeHostTestPinchZoomScrollbarNewRootLayer)
+
} // namespace
} // namespace cc
« no previous file with comments | « cc/layer_tree_host_impl.cc ('k') | cc/layer_tree_impl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698