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

Unified Diff: cc/scrollbar_layer_unittest.cc

Issue 12297009: cc: SolidColorQuad-based scrollbars for Android [M25] (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rename to solidColorScrollbarThicknessDIP Created 7 years, 10 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
Index: cc/scrollbar_layer_unittest.cc
diff --git a/cc/scrollbar_layer_unittest.cc b/cc/scrollbar_layer_unittest.cc
index fa5cd63eb35a66baecf3748c355c494e307d4264..a788133f49a0eb82839b5c55481514382d47c93c 100644
--- a/cc/scrollbar_layer_unittest.cc
+++ b/cc/scrollbar_layer_unittest.cc
@@ -4,10 +4,14 @@
#include "cc/scrollbar_layer.h"
+#include "cc/prioritized_resource_manager.h"
+#include "cc/priority_calculator.h"
+#include "cc/resource_update_queue.h"
#include "cc/scrollbar_animation_controller.h"
#include "cc/scrollbar_layer_impl.h"
#include "cc/single_thread_proxy.h"
#include "cc/test/fake_impl_proxy.h"
+#include "cc/test/fake_layer_tree_host_client.h"
#include "cc/test/fake_layer_tree_host_impl.h"
#include "cc/test/fake_scrollbar_theme_painter.h"
#include "cc/test/fake_web_scrollbar.h"
@@ -15,6 +19,7 @@
#include "cc/test/layer_tree_test_common.h"
#include "cc/test/test_web_graphics_context_3d.h"
#include "cc/tree_synchronizer.h"
+#include "testing/gmock/include/gmock/gmock.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "third_party/WebKit/Source/Platform/chromium/public/WebScrollbar.h"
#include "third_party/WebKit/Source/Platform/chromium/public/WebScrollbarThemeGeometry.h"
@@ -194,5 +199,82 @@ TEST_F(ScrollbarLayerTestMaxTextureSize, runTest) {
runTest(true);
}
+class MockLayerTreeHost : public LayerTreeHost {
+public:
+ MockLayerTreeHost(const LayerTreeSettings& settings)
+ : LayerTreeHost(&m_fakeClient, settings)
+ {
+ initialize(scoped_ptr<Thread>(NULL));
+ }
+
+private:
+ FakeLayerImplTreeHostClient m_fakeClient;
+};
+
+
+class ScrollbarLayerTestResourceCreation : public testing::Test {
+public:
+ ScrollbarLayerTestResourceCreation()
+ {
+ }
+
+ void testResourceUpload(int expectedResources)
+ {
+ m_layerTreeHost.reset(new MockLayerTreeHost(m_layerTreeSettings));
+
+ scoped_ptr<WebKit::WebScrollbar> scrollbar(FakeWebScrollbar::create());
+ scoped_refptr<Layer> layerTreeRoot = Layer::create();
+ scoped_refptr<Layer> contentLayer = Layer::create();
+ scoped_refptr<Layer> scrollbarLayer = ScrollbarLayer::create(scrollbar.Pass(), FakeScrollbarThemePainter::Create(false).PassAs<ScrollbarThemePainter>(), FakeWebScrollbarThemeGeometry::create(true), layerTreeRoot->id());
+ layerTreeRoot->addChild(contentLayer);
+ layerTreeRoot->addChild(scrollbarLayer);
+
+ m_layerTreeHost->initializeRendererIfNeeded();
+ m_layerTreeHost->contentsTextureManager()->setMaxMemoryLimitBytes(1024 * 1024);
+ m_layerTreeHost->setRootLayer(layerTreeRoot);
+
+ scrollbarLayer->setIsDrawable(true);
+ scrollbarLayer->setBounds(gfx::Size(100, 100));
+ layerTreeRoot->setScrollOffset(gfx::Vector2d(10, 20));
+ layerTreeRoot->setMaxScrollOffset(gfx::Vector2d(30, 50));
+ layerTreeRoot->setBounds(gfx::Size(100, 200));
+ contentLayer->setBounds(gfx::Size(100, 200));
+ scrollbarLayer->drawProperties().content_bounds = gfx::Size(100, 200);
+ scrollbarLayer->drawProperties().visible_content_rect = gfx::Rect(0, 0, 100, 200);
+ scrollbarLayer->drawProperties().render_target = scrollbarLayer;
+
+ testing::Mock::VerifyAndClearExpectations(m_layerTreeHost.get());
+ EXPECT_EQ(scrollbarLayer->layerTreeHost(), m_layerTreeHost.get());
+
+ PriorityCalculator calculator;
+ ResourceUpdateQueue queue;
+ OcclusionTracker occlusionTracker(gfx::Rect(), false);
+
+ scrollbarLayer->setTexturePriorities(calculator);
+ m_layerTreeHost->contentsTextureManager()->prioritizeTextures();
+ scrollbarLayer->update(queue, &occlusionTracker, NULL);
+ EXPECT_EQ(0, queue.fullUploadSize());
+ EXPECT_EQ(expectedResources, queue.partialUploadSize());
+
+ testing::Mock::VerifyAndClearExpectations(m_layerTreeHost.get());
+ }
+
+protected:
+ scoped_ptr<MockLayerTreeHost> m_layerTreeHost;
+ LayerTreeSettings m_layerTreeSettings;
+};
+
+TEST_F(ScrollbarLayerTestResourceCreation, resourceUpload)
+{
+ m_layerTreeSettings.solidColorScrollbars = false;
+ testResourceUpload(2);
+}
+
+TEST_F(ScrollbarLayerTestResourceCreation, solidColorNoResourceUpload)
+{
+ m_layerTreeSettings.solidColorScrollbars = true;
+ testResourceUpload(0);
+}
+
} // namespace
} // namespace cc

Powered by Google App Engine
This is Rietveld 408576698