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

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: rebase & fix mistake 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 <gtest/gtest.h> 13 #include <gtest/gtest.h>
14 #include <memory> 14 #include <memory>
15 15
16 namespace blink { 16 namespace blink {
17 17
18 using HTMLNames::styleAttr; 18 using HTMLNames::styleAttr;
19 19
20 typedef bool TestParamRootLayerScrolling;
20 class SnapCoordinatorTest 21 class SnapCoordinatorTest
21 : public testing::TestWithParam<FrameSettingOverrideFunction> { 22 : public testing::TestWithParam<TestParamRootLayerScrolling> {
22 protected: 23 protected:
23 SnapCoordinatorTest() {} 24 SnapCoordinatorTest()
25 : m_originalRootLayerScrollingEnabled(RuntimeEnabledFeatures::rootLayerS crollingEnabled())
26 , m_enableRootLayerScrolling(GetParam())
27 {
28 RuntimeEnabledFeatures::setRootLayerScrollingEnabled(m_enableRootLayerSc rolling);
29 }
30
31 ~SnapCoordinatorTest()
32 {
33 CHECK_EQ(m_enableRootLayerScrolling, RuntimeEnabledFeatures::rootLayerSc rollingEnabled());
34 RuntimeEnabledFeatures::setRootLayerScrollingEnabled(m_originalRootLayer ScrollingEnabled);
35 }
24 36
25 void SetUp() override 37 void SetUp() override
26 { 38 {
27 m_pageHolder = DummyPageHolder::create( 39 m_pageHolder = DummyPageHolder::create();
28 IntSize(), nullptr, nullptr, GetParam());
29 40
30 setHTML( 41 setHTML(
31 "<style>" 42 "<style>"
32 " #snap-container {" 43 " #snap-container {"
33 " height: 1000px;" 44 " height: 1000px;"
34 " width: 1000px;" 45 " width: 1000px;"
35 " overflow: scroll;" 46 " overflow: scroll;"
36 " scroll-snap-type: mandatory;" 47 " scroll-snap-type: mandatory;"
37 " }" 48 " }"
38 " #snap-element-fixed-position {" 49 " #snap-element-fixed-position {"
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
76 { 87 {
77 return *document().snapCoordinator(); 88 return *document().snapCoordinator();
78 } 89 }
79 90
80 Vector<double> snapOffsets(const ContainerNode& node, ScrollbarOrientation o rientation) 91 Vector<double> snapOffsets(const ContainerNode& node, ScrollbarOrientation o rientation)
81 { 92 {
82 return coordinator().snapOffsets(node, orientation); 93 return coordinator().snapOffsets(node, orientation);
83 } 94 }
84 95
85 std::unique_ptr<DummyPageHolder> m_pageHolder; 96 std::unique_ptr<DummyPageHolder> m_pageHolder;
97 bool m_originalRootLayerScrollingEnabled;
98 bool m_enableRootLayerScrolling;
86 }; 99 };
87 100
88 INSTANTIATE_TEST_CASE_P(All, SnapCoordinatorTest, ::testing::Values( 101 INSTANTIATE_TEST_CASE_P(All, SnapCoordinatorTest, ::testing::Bool());
89 nullptr,
90 RootLayerScrollsFrameSettingOverride));
91 102
92 TEST_P(SnapCoordinatorTest, ValidRepeat) 103 TEST_P(SnapCoordinatorTest, ValidRepeat)
93 { 104 {
94 snapContainer().setAttribute(styleAttr, "scroll-snap-points-x: repeat(20%); scroll-snap-points-y: repeat(400px);"); 105 snapContainer().setAttribute(styleAttr, "scroll-snap-points-x: repeat(20%); scroll-snap-points-y: repeat(400px);");
95 document().updateStyleAndLayout(); 106 document().updateStyleAndLayout();
96 { 107 {
97 const int expectedStepSize = snapContainer().clientWidth() * 0.2; 108 const int expectedStepSize = snapContainer().clientWidth() * 0.2;
98 Vector<double> actual = snapOffsets(snapContainer(), HorizontalScrollbar ); 109 Vector<double> actual = snapOffsets(snapContainer(), HorizontalScrollbar );
99 EXPECT_EQ(5U, actual.size()); 110 EXPECT_EQ(5U, actual.size());
100 for (size_t i = 0; i < actual.size(); ++i) 111 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); 390 Vector<double> result = snapOffsets(body, HorizontalScrollbar);
380 EXPECT_EQ(5, result[0]); 391 EXPECT_EQ(5, result[0]);
381 EXPECT_EQ(10, result[1]); 392 EXPECT_EQ(10, result[1]);
382 result = snapOffsets(body, VerticalScrollbar); 393 result = snapOffsets(body, VerticalScrollbar);
383 EXPECT_EQ(6, result[0]); 394 EXPECT_EQ(6, result[0]);
384 EXPECT_EQ(11, result[1]); 395 EXPECT_EQ(11, result[1]);
385 } 396 }
386 397
387 398
388 } // namespace 399 } // namespace
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698