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

Side by Side Diff: third_party/WebKit/Source/core/page/scrolling/SnapCoordinatorTest.cpp

Issue 2258523006: Convert Settings::rootLayerScrolls to RuntimeEnabledFeatures (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Add RAII-style helper to toggle REF. Rebase. Created 4 years, 3 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 unified diff | Download patch
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "SnapCoordinator.h" 5 #include "SnapCoordinator.h"
6 6
7 #include "core/dom/Document.h" 7 #include "core/dom/Document.h"
8 #include "core/dom/Element.h" 8 #include "core/dom/Element.h"
9 #include "core/frame/FrameView.h" 9 #include "core/frame/FrameView.h"
10 #include "core/style/ComputedStyle.h" 10 #include "core/style/ComputedStyle.h"
11 #include "core/testing/DummyPageHolder.h" 11 #include "core/testing/DummyPageHolder.h"
12 #include "platform/scroll/ScrollTypes.h" 12 #include "platform/scroll/ScrollTypes.h"
13 #include "platform/testing/RuntimeEnabledFeaturesTestHelpers.h"
13 #include <gtest/gtest.h> 14 #include <gtest/gtest.h>
14 #include <memory> 15 #include <memory>
15 16
16 namespace blink { 17 namespace blink {
17 18
18 using HTMLNames::styleAttr; 19 using HTMLNames::styleAttr;
19 20
21 typedef bool TestParamRootLayerScrolling;
20 class SnapCoordinatorTest 22 class SnapCoordinatorTest
21 : public testing::TestWithParam<FrameSettingOverrideFunction> { 23 : public testing::TestWithParam<TestParamRootLayerScrolling>
24 , private ScopedRootLayerScrollingForTest {
22 protected: 25 protected:
23 SnapCoordinatorTest() {} 26 SnapCoordinatorTest() : ScopedRootLayerScrollingForTest(GetParam()) { }
24 27
25 void SetUp() override 28 void SetUp() override
26 { 29 {
27 m_pageHolder = DummyPageHolder::create( 30 m_pageHolder = DummyPageHolder::create();
28 IntSize(), nullptr, nullptr, GetParam());
29 31
30 setHTML( 32 setHTML(
31 "<style>" 33 "<style>"
32 " #snap-container {" 34 " #snap-container {"
33 " height: 1000px;" 35 " height: 1000px;"
34 " width: 1000px;" 36 " width: 1000px;"
35 " overflow: scroll;" 37 " overflow: scroll;"
36 " scroll-snap-type: mandatory;" 38 " scroll-snap-type: mandatory;"
37 " }" 39 " }"
38 " #snap-element-fixed-position {" 40 " #snap-element-fixed-position {"
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
78 } 80 }
79 81
80 Vector<double> snapOffsets(const ContainerNode& node, ScrollbarOrientation o rientation) 82 Vector<double> snapOffsets(const ContainerNode& node, ScrollbarOrientation o rientation)
81 { 83 {
82 return coordinator().snapOffsets(node, orientation); 84 return coordinator().snapOffsets(node, orientation);
83 } 85 }
84 86
85 std::unique_ptr<DummyPageHolder> m_pageHolder; 87 std::unique_ptr<DummyPageHolder> m_pageHolder;
86 }; 88 };
87 89
88 INSTANTIATE_TEST_CASE_P(All, SnapCoordinatorTest, ::testing::Values( 90 INSTANTIATE_TEST_CASE_P(All, SnapCoordinatorTest, ::testing::Bool());
89 nullptr,
90 RootLayerScrollsFrameSettingOverride));
91 91
92 TEST_P(SnapCoordinatorTest, ValidRepeat) 92 TEST_P(SnapCoordinatorTest, ValidRepeat)
93 { 93 {
94 snapContainer().setAttribute(styleAttr, "scroll-snap-points-x: repeat(20%); scroll-snap-points-y: repeat(400px);"); 94 snapContainer().setAttribute(styleAttr, "scroll-snap-points-x: repeat(20%); scroll-snap-points-y: repeat(400px);");
95 document().updateStyleAndLayout(); 95 document().updateStyleAndLayout();
96 { 96 {
97 const int expectedStepSize = snapContainer().clientWidth() * 0.2; 97 const int expectedStepSize = snapContainer().clientWidth() * 0.2;
98 Vector<double> actual = snapOffsets(snapContainer(), HorizontalScrollbar ); 98 Vector<double> actual = snapOffsets(snapContainer(), HorizontalScrollbar );
99 EXPECT_EQ(5U, actual.size()); 99 EXPECT_EQ(5U, actual.size());
100 for (size_t i = 0; i < actual.size(); ++i) 100 for (size_t i = 0; i < actual.size(); ++i)
(...skipping 278 matching lines...) Expand 10 before | Expand all | Expand 10 after
379 Vector<double> result = snapOffsets(body, HorizontalScrollbar); 379 Vector<double> result = snapOffsets(body, HorizontalScrollbar);
380 EXPECT_EQ(5, result[0]); 380 EXPECT_EQ(5, result[0]);
381 EXPECT_EQ(10, result[1]); 381 EXPECT_EQ(10, result[1]);
382 result = snapOffsets(body, VerticalScrollbar); 382 result = snapOffsets(body, VerticalScrollbar);
383 EXPECT_EQ(6, result[0]); 383 EXPECT_EQ(6, result[0]);
384 EXPECT_EQ(11, result[1]); 384 EXPECT_EQ(11, result[1]);
385 } 385 }
386 386
387 387
388 } // namespace 388 } // namespace
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698