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

Unified 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 side-by-side diff with in-line comments
Download patch
Index: third_party/WebKit/Source/core/css/resolver/StyleAdjusterTest.cpp
diff --git a/third_party/WebKit/Source/core/css/resolver/StyleAdjusterTest.cpp b/third_party/WebKit/Source/core/css/resolver/StyleAdjusterTest.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..aafcb1d3f6e241a2d0fd35b83a34da5f9b472300
--- /dev/null
+++ b/third_party/WebKit/Source/core/css/resolver/StyleAdjusterTest.cpp
@@ -0,0 +1,89 @@
+// Copyright 2017 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "core/layout/LayoutTestHelper.h"
+#include "platform/testing/RuntimeEnabledFeaturesTestHelpers.h"
+#include "testing/gtest/include/gtest/gtest.h"
+
+namespace blink {
+
+class StyleAdjusterTest : public RenderingTest {
+ public:
+ StyleAdjusterTest() : RenderingTest(SingleChildLocalFrameClient::Create()) {}
+};
+
+TEST_F(StyleAdjusterTest, TouchActionPropagatedAcrossIframes) {
+ GetDocument().SetBaseURLOverride(KURL(kParsedURLString, "http://test.com"));
+ SetBodyInnerHTML(
+ "<style>body { margin: 0; } iframe { display: block; } </style>"
+ "<iframe id='owner' src='http://test.com' width='500' height='500' "
+ "style='touch-action: none'>"
+ "</iframe>");
+ SetChildFrameHTML(
+ "<style>body { margin: 0; } #target { width: 200px; height: 200px; } "
+ "</style>"
+ "<div id='target' style='touch-action: pinch-zoom'></div>");
+ GetDocument().View()->UpdateAllLifecyclePhases();
+
+ Element* target = ChildDocument().getElementById("target");
+ 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.
+ EXPECT_EQ(TouchAction::kTouchActionNone,
+ target->GetComputedStyle()->GetEffectiveTouchAction());
+
+ Element* owner = GetDocument().getElementById("owner");
+ ASSERT_TRUE(owner);
+ owner->setAttribute(HTMLNames::styleAttr, "touch-action: auto");
+ GetDocument().View()->UpdateAllLifecyclePhases();
+ EXPECT_EQ(TouchAction::kTouchActionPinchZoom,
+ target->GetComputedStyle()->GetEffectiveTouchAction());
+}
+
+TEST_F(StyleAdjusterTest, TouchActionPanningReEnabledByScrolles) {
flackr 2017/06/22 19:15:31 nit:s/Scrolles/Scroller
sunxd 2017/06/26 17:52:01 Done.
+ GetDocument().SetBaseURLOverride(KURL(kParsedURLString, "http://test.com"));
+ SetBodyInnerHTML(
+ "<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.
+ "#scroller { overflow: scroll; width: 100px; height: 100px; } "
+ "#target { width: 200px; height: 200px; } </style>"
+ "<div id='ancestor'><div id='scroller'><div id='target'>"
+ "</div></div></div>");
+ GetDocument().View()->UpdateAllLifecyclePhases();
+
+ Element* target = GetDocument().getElementById("target");
+ ASSERT_TRUE(target && target->GetComputedStyle());
+ EXPECT_EQ(TouchAction::kTouchActionPan,
+ target->GetComputedStyle()->GetEffectiveTouchAction());
+}
+
+TEST_F(StyleAdjusterTest, TouchActionPropagatedWhenAncestorStyleChanges) {
+ GetDocument().SetBaseURLOverride(KURL(kParsedURLString, "http://test.com"));
+ SetBodyInnerHTML(
+ "<style>#ancestor { margin: 0; touch-action: pan-x; } "
+ "#potential-scroller { width: 100px; height: 100px; overflow: hidden; } "
+ "#target { width: 200px; height: 200px; }</style>"
+ "<div id='ancestor'><div id='potential-scroller'><div id='target'>"
+ "</div></div></div>");
+ GetDocument().View()->UpdateAllLifecyclePhases();
+
+ Element* target = GetDocument().getElementById("target");
+ ASSERT_TRUE(target && target->GetComputedStyle());
+ EXPECT_EQ(TouchAction::kTouchActionPanX,
+ target->GetComputedStyle()->GetEffectiveTouchAction());
+
+ Element* ancestor = GetDocument().getElementById("ancestor");
+ ASSERT_TRUE(ancestor);
+ ancestor->setAttribute(HTMLNames::styleAttr, "touch-action: pan-y");
+ GetDocument().View()->UpdateAllLifecyclePhases();
+ EXPECT_EQ(TouchAction::kTouchActionPanY,
+ target->GetComputedStyle()->GetEffectiveTouchAction());
+
+ Element* potential_scroller =
+ GetDocument().getElementById("potential-scroller");
+ ASSERT_TRUE(potential_scroller);
+ potential_scroller->setAttribute(HTMLNames::styleAttr, "overflow: scroll");
+ GetDocument().View()->UpdateAllLifecyclePhases();
+ EXPECT_EQ(TouchAction::kTouchActionPan,
+ target->GetComputedStyle()->GetEffectiveTouchAction());
+}
+
+} // namespace blink
« 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