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

Unified Diff: cc/layers/scrollbar_layer_unittest.cc

Issue 2803853007: Ignore rounding error between clip_layer_length_ and scroll_layer_length_ (Closed)
Patch Set: add page_scale Created 3 years, 8 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/layers/scrollbar_layer_unittest.cc
diff --git a/cc/layers/scrollbar_layer_unittest.cc b/cc/layers/scrollbar_layer_unittest.cc
index 65cd0610bde1a8db191421d2deb9484895c7066c..d2dd0af3b3f948d7694190c5cdfd897dad520056 100644
--- a/cc/layers/scrollbar_layer_unittest.cc
+++ b/cc/layers/scrollbar_layer_unittest.cc
@@ -26,6 +26,7 @@
#include "cc/test/fake_painted_scrollbar_layer.h"
#include "cc/test/fake_scrollbar.h"
#include "cc/test/geometry_test_utils.h"
+#include "cc/test/layer_test_common.h"
#include "cc/test/layer_tree_test.h"
#include "cc/test/mock_occlusion_tracker.h"
#include "cc/test/stub_layer_tree_host_single_thread_client.h"
@@ -769,6 +770,48 @@ TEST_F(ScrollbarLayerTest, ScrollbarLayerPushProperties) {
EXPECT_EQ(node->opacity, 1.f);
}
+TEST_F(ScrollbarLayerTest, SubPixelCanScrollOrientation) {
+ gfx::Size viewport_size(100, 100);
+
+ LayerTestCommon::LayerImplTest impl;
+
+ LayerImpl* clip_layer = impl.AddChildToRoot<LayerImpl>();
+ LayerImpl* scroll_layer = impl.AddChild<LayerImpl>(clip_layer);
+
+ scroll_layer->SetScrollClipLayer(clip_layer->id());
+
+ const int kTrackStart = 0;
+ const int kThumbThickness = 10;
+ const bool kIsLeftSideVerticalScrollbar = false;
+ const bool kIsOverlayScrollbar = false;
+
+ SolidColorScrollbarLayerImpl* scrollbar_layer =
+ impl.AddChild<SolidColorScrollbarLayerImpl>(
+ scroll_layer, HORIZONTAL, kThumbThickness, kTrackStart,
+ kIsLeftSideVerticalScrollbar, kIsOverlayScrollbar);
+
+ scrollbar_layer->SetScrollInfo(scroll_layer->id(),
+ scrollbar_layer->element_id());
+ clip_layer->SetBounds(gfx::Size(100, 100));
+ scroll_layer->SetBounds(gfx::Size(100, 100));
+
+ impl.CalcDrawProps(viewport_size);
+
+ // Fake device scale.
+ impl.host_impl()->active_tree()->SetDeviceScaleFactor(3);
+
+ // Fake clip layer length to scrollbar to mock rounding error.
+ scrollbar_layer->SetClipLayerLength(99.99f);
+
+ EXPECT_FALSE(scrollbar_layer->CanScrollOrientation());
+
+ // Fake clip layer length to scrollbar to 1 device pixel shorter than scroll
+ // layer.
+ scrollbar_layer->SetClipLayerLength(99.65f);
+
+ EXPECT_TRUE(scrollbar_layer->CanScrollOrientation());
+}
+
class ScrollbarLayerSolidColorThumbTest : public testing::Test {
public:
ScrollbarLayerSolidColorThumbTest() {

Powered by Google App Engine
This is Rietveld 408576698