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

Unified Diff: cc/layers/scrollbar_layer_unittest.cc

Issue 2803853007: Ignore rounding error between clip_layer_length_ and scroll_layer_length_ (Closed)
Patch Set: expose IsFloatNearlyTheSame & add comment 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
« no previous file with comments | « cc/layers/scrollbar_layer_impl_base.cc ('k') | cc/test/layer_test_common.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: cc/layers/scrollbar_layer_unittest.cc
diff --git a/cc/layers/scrollbar_layer_unittest.cc b/cc/layers/scrollbar_layer_unittest.cc
index 3120dbfe34e8e6d4bf7f5d4c13a6bf9741ef68c6..b38a818d95fd47ad43297bbb89e577c0f869c816 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"
@@ -762,6 +763,44 @@ TEST_F(ScrollbarLayerTest, ScrollbarLayerPushProperties) {
EXPECT_EQ(node->opacity, 1.f);
}
+TEST_F(ScrollbarLayerTest, SubPixelCanScrollOrientation) {
+ gfx::Size viewport_size(980, 980);
+
+ LayerTestCommon::LayerImplTest impl;
+
+ LayerImpl* clip_layer = impl.AddChildToRoot<LayerImpl>();
+ LayerImpl* scroll_layer = impl.AddChild<LayerImpl>(clip_layer);
+
+ scroll_layer->SetScrollClipLayer(clip_layer->id());
+ scroll_layer->SetElementId(LayerIdToElementIdForTesting(scroll_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->SetScrollElementId(scroll_layer->element_id());
+ clip_layer->SetBounds(gfx::Size(980, 980));
+ scroll_layer->SetBounds(gfx::Size(980, 980));
+
+ impl.CalcDrawProps(viewport_size);
+
+ // Fake clip layer length to scrollbar to mock rounding error.
+ scrollbar_layer->SetClipLayerLength(979.999939f);
+
+ EXPECT_FALSE(scrollbar_layer->CanScrollOrientation());
+
+ // Fake clip layer length to scrollable.
+ scrollbar_layer->SetClipLayerLength(979.0f);
+
+ EXPECT_TRUE(scrollbar_layer->CanScrollOrientation());
+}
+
class ScrollbarLayerSolidColorThumbTest : public testing::Test {
public:
ScrollbarLayerSolidColorThumbTest() {
« no previous file with comments | « cc/layers/scrollbar_layer_impl_base.cc ('k') | cc/test/layer_test_common.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698