OLD | NEW |
---|---|
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 "core/layout/ScrollAnchor.h" | 5 #include "core/layout/ScrollAnchor.h" |
6 | 6 |
7 #include "core/layout/LayoutTestHelper.h" | 7 #include "core/layout/LayoutTestHelper.h" |
8 | 8 |
9 namespace blink { | 9 namespace blink { |
10 | 10 |
11 static void enableScrollAnchoring(Settings& settings) | 11 static void enableScrollAnchoring(Settings& settings) |
12 { | 12 { |
13 settings.setScrollAnchoringEnabled(true); | 13 settings.setScrollAnchoringEnabled(true); |
14 } | 14 } |
15 | 15 |
16 class ScrollAnchorTest : public RenderingTest { | 16 class ScrollAnchorTest : public RenderingTest { |
ojan
2016/02/03 01:37:03
I think this might be better as a SimTest. See htt
skobes
2016/02/06 01:02:17
This is made tricky by SimTest being in web instea
| |
17 FrameSettingOverrideFunction settingOverrider() const override { return enab leScrollAnchoring; } | 17 FrameSettingOverrideFunction settingOverrider() const override { return enab leScrollAnchoring; } |
18 }; | 18 }; |
19 | 19 |
20 TEST_F(ScrollAnchorTest, Basic) | 20 TEST_F(ScrollAnchorTest, Basic) |
21 { | 21 { |
22 ScrollAnchor scrollAnchor(document().view()->layoutViewportScrollableArea()) ; | 22 setBodyInnerHTML( |
23 scrollAnchor.clear(); | 23 "<style> body { height: 1000px } div { height: 100px } </style>" |
24 EXPECT_EQ(nullptr, scrollAnchor.anchorObject()); | 24 "<div id='block1'>abc</div>" |
25 "<div id='block2'>def</div>"); | |
26 | |
27 ScrollableArea* viewport = document().view()->layoutViewportScrollableArea() ; | |
28 viewport->scrollBy(DoubleSize(0, 150), UserScroll); | |
29 document().getElementById("block1")->setAttribute(HTMLNames::styleAttr, "hei ght: 200px"); | |
30 document().view()->updateAllLifecyclePhases(); | |
31 EXPECT_EQ(250, viewport->scrollPosition().y()); | |
25 } | 32 } |
33 | |
26 } | 34 } |
OLD | NEW |