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

Side by Side Diff: third_party/WebKit/Source/core/css/resolver/StyleAdjusterTest.cpp

Issue 2916563003: Compute effective touch action in StyleAdjuster. (Closed)
Patch Set: Add StyleAdjusterTest Created 3 years, 6 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
(Empty)
1 // Copyright 2017 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include "core/layout/LayoutTestHelper.h"
6 #include "platform/testing/RuntimeEnabledFeaturesTestHelpers.h"
7 #include "testing/gtest/include/gtest/gtest.h"
8
9 namespace blink {
10
11 class StyleAdjusterTest : public RenderingTest {
12 public:
13 StyleAdjusterTest() : RenderingTest(SingleChildLocalFrameClient::Create()) {}
14 };
15
16 TEST_F(StyleAdjusterTest, TouchActionPropagatedAcrossIframes) {
17 GetDocument().SetBaseURLOverride(KURL(kParsedURLString, "http://test.com"));
18 SetBodyInnerHTML(
19 "<style>body { margin: 0; } iframe { display: block; } </style>"
20 "<iframe id='owner' src='http://test.com' width='500' height='500' "
21 "style='touch-action: none'>"
22 "</iframe>");
23 SetChildFrameHTML(
24 "<style>body { margin: 0; } #target { width: 200px; height: 200px; } "
25 "</style>"
26 "<div id='target' style='touch-action: pinch-zoom'></div>");
27 GetDocument().View()->UpdateAllLifecyclePhases();
28
29 Element* target = ChildDocument().getElementById("target");
30 ASSERT_TRUE(target && target->GetComputedStyle());
flackr 2017/06/22 19:15:31 These asserts are unnecessary - it will crash if t
sunxd 2017/06/26 17:52:01 Done.
31 EXPECT_EQ(TouchAction::kTouchActionNone,
32 target->GetComputedStyle()->GetEffectiveTouchAction());
33
34 Element* owner = GetDocument().getElementById("owner");
35 ASSERT_TRUE(owner);
36 owner->setAttribute(HTMLNames::styleAttr, "touch-action: auto");
37 GetDocument().View()->UpdateAllLifecyclePhases();
38 EXPECT_EQ(TouchAction::kTouchActionPinchZoom,
39 target->GetComputedStyle()->GetEffectiveTouchAction());
40 }
41
42 TEST_F(StyleAdjusterTest, TouchActionPanningReEnabledByScrolles) {
flackr 2017/06/22 19:15:31 nit:s/Scrolles/Scroller
sunxd 2017/06/26 17:52:01 Done.
43 GetDocument().SetBaseURLOverride(KURL(kParsedURLString, "http://test.com"));
44 SetBodyInnerHTML(
45 "<style>#ancestor { margin: 0; touch-action: none; } "
flackr 2017/06/22 19:15:31 Can we set something like pinch-zoom to verify tha
sunxd 2017/06/26 17:52:01 Done.
46 "#scroller { overflow: scroll; width: 100px; height: 100px; } "
47 "#target { width: 200px; height: 200px; } </style>"
48 "<div id='ancestor'><div id='scroller'><div id='target'>"
49 "</div></div></div>");
50 GetDocument().View()->UpdateAllLifecyclePhases();
51
52 Element* target = GetDocument().getElementById("target");
53 ASSERT_TRUE(target && target->GetComputedStyle());
54 EXPECT_EQ(TouchAction::kTouchActionPan,
55 target->GetComputedStyle()->GetEffectiveTouchAction());
56 }
57
58 TEST_F(StyleAdjusterTest, TouchActionPropagatedWhenAncestorStyleChanges) {
59 GetDocument().SetBaseURLOverride(KURL(kParsedURLString, "http://test.com"));
60 SetBodyInnerHTML(
61 "<style>#ancestor { margin: 0; touch-action: pan-x; } "
62 "#potential-scroller { width: 100px; height: 100px; overflow: hidden; } "
63 "#target { width: 200px; height: 200px; }</style>"
64 "<div id='ancestor'><div id='potential-scroller'><div id='target'>"
65 "</div></div></div>");
66 GetDocument().View()->UpdateAllLifecyclePhases();
67
68 Element* target = GetDocument().getElementById("target");
69 ASSERT_TRUE(target && target->GetComputedStyle());
70 EXPECT_EQ(TouchAction::kTouchActionPanX,
71 target->GetComputedStyle()->GetEffectiveTouchAction());
72
73 Element* ancestor = GetDocument().getElementById("ancestor");
74 ASSERT_TRUE(ancestor);
75 ancestor->setAttribute(HTMLNames::styleAttr, "touch-action: pan-y");
76 GetDocument().View()->UpdateAllLifecyclePhases();
77 EXPECT_EQ(TouchAction::kTouchActionPanY,
78 target->GetComputedStyle()->GetEffectiveTouchAction());
79
80 Element* potential_scroller =
81 GetDocument().getElementById("potential-scroller");
82 ASSERT_TRUE(potential_scroller);
83 potential_scroller->setAttribute(HTMLNames::styleAttr, "overflow: scroll");
84 GetDocument().View()->UpdateAllLifecyclePhases();
85 EXPECT_EQ(TouchAction::kTouchActionPan,
86 target->GetComputedStyle()->GetEffectiveTouchAction());
87 }
88
89 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/css/resolver/StyleAdjuster.cpp ('k') | third_party/WebKit/Source/core/dom/StyleChangeReason.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698