Commit 59f28009 authored by David Bokan's avatar David Bokan Committed by Commit Bot

Convert root scroller HitTesting tests to SimTest

Bug: 798719
Change-Id: I371d41833373fe54efeb844a338840b7d862784c
Reviewed-on: https://chromium-review.googlesource.com/c/1287188Reviewed-by: default avatarDave Tapuska <dtapuska@chromium.org>
Commit-Queue: David Bokan <bokan@chromium.org>
Cr-Commit-Position: refs/heads/master@{#600753}
parent 98bcd32d
...@@ -2464,7 +2464,7 @@ TEST_F(ImplicitRootScrollerSimTest, AppliedAtFractionalZoom) { ...@@ -2464,7 +2464,7 @@ TEST_F(ImplicitRootScrollerSimTest, AppliedAtFractionalZoom) {
<< "<iframe> should remain promoted when URL bar is hidden"; << "<iframe> should remain promoted when URL bar is hidden";
} }
class RootScrollerHitTest : public RootScrollerTest { class RootScrollerHitTest : public RootScrollerSimTest {
public: public:
void CheckHitTestAtBottomOfScreen() { void CheckHitTestAtBottomOfScreen() {
HideTopControlsWithMaximalScroll(); HideTopControlsWithMaximalScroll();
...@@ -2475,31 +2475,38 @@ class RootScrollerHitTest : public RootScrollerTest { ...@@ -2475,31 +2475,38 @@ class RootScrollerHitTest : public RootScrollerTest {
// target. // target.
WebPoint point(200, 445); WebPoint point(200, 445);
WebSize tap_area(20, 20); WebSize tap_area(20, 20);
WebHitTestResult result = WebHitTestResult result = WebView().HitTestResultForTap(point, tap_area);
GetWebView()->HitTestResultForTap(point, tap_area);
Node* hit_node = result.GetNode().Unwrap<Node>(); Node* hit_node = result.GetNode().Unwrap<Node>();
Element* target = MainFrame()->GetDocument()->getElementById("target"); Element* target = GetDocument().getElementById("target");
ASSERT_TRUE(target); ASSERT_TRUE(target);
EXPECT_EQ(target, hit_node); EXPECT_EQ(target, hit_node);
} }
BrowserControls& GetBrowserControls() {
return GetDocument().GetPage()->GetBrowserControls();
}
private: private:
void HideTopControlsWithMaximalScroll() { void HideTopControlsWithMaximalScroll() {
// Do a scroll gesture that hides the top controls and scrolls all the way // Do a scroll gesture that hides the top controls and scrolls all the way
// to the bottom. // to the bottom.
GetWebView()->HandleInputEvent(
GenerateTouchGestureEvent(WebInputEvent::kGestureScrollBegin));
ASSERT_EQ(1, GetBrowserControls().ShownRatio()); ASSERT_EQ(1, GetBrowserControls().ShownRatio());
GetWebView()->HandleInputEvent( WebView().ApplyViewportChanges({gfx::Vector2dF(), gfx::Vector2dF(), 1, -1,
GenerateTouchGestureEvent(WebInputEvent::kGestureScrollUpdate, 0, cc::BrowserControlsState::kBoth});
-GetBrowserControls().TopHeight()));
ASSERT_EQ(0, GetBrowserControls().ShownRatio()); ASSERT_EQ(0, GetBrowserControls().ShownRatio());
GetWebView()->HandleInputEvent(GenerateTouchGestureEvent(
WebInputEvent::kGestureScrollUpdate, 0, -100000)); Element* scroller = GetDocument()
GetWebView()->HandleInputEvent( .GetPage()
GenerateTouchGestureEvent(WebInputEvent::kGestureScrollEnd)); ->GlobalRootScrollerController()
GetWebView()->ResizeWithBrowserControls(IntSize(400, 450), 50, 0, false); .GlobalRootScroller();
ScrollableArea* scrollable_area =
ToLayoutBox(scroller->GetLayoutObject())->GetScrollableArea();
scrollable_area->DidScroll(FloatPoint(0, 100000));
WebView().ResizeWithBrowserControls(IntSize(400, 450), 50, 0, false);
Compositor().BeginFrame();
} }
}; };
...@@ -2508,42 +2515,46 @@ class RootScrollerHitTest : public RootScrollerTest { ...@@ -2508,42 +2515,46 @@ class RootScrollerHitTest : public RootScrollerTest {
// when the target and scroller are in the same PaintLayer. // when the target and scroller are in the same PaintLayer.
// TODO(chrishtr): fix this for root scrollers. // TODO(chrishtr): fix this for root scrollers.
TEST_F(RootScrollerHitTest, DISABLED_HitTestInAreaRevealedByURLBarSameLayer) { TEST_F(RootScrollerHitTest, DISABLED_HitTestInAreaRevealedByURLBarSameLayer) {
WebView().ResizeWithBrowserControls(IntSize(400, 400), 50, 0, true);
GetBrowserControls().SetShownRatio(1);
SimRequest request("https://example.com/test.html", "text/html");
LoadURL("https://example.com/test.html");
// Add a target at the bottom of the root scroller that's the size of the url // Add a target at the bottom of the root scroller that's the size of the url
// bar. We'll test that hiding the URL bar appropriately adjusts clipping so // bar. We'll test that hiding the URL bar appropriately adjusts clipping so
// that we can hit this target. // that we can hit this target.
Initialize(); request.Complete(R"HTML(
WebURL baseURL = URLTestHelpers::ToKURL("http://www.test.com/"); <!DOCTYPE html>
FrameTestHelpers::LoadHTMLString(GetWebView()->MainFrameImpl(), <style>
"<!DOCTYPE html>" body, html {
"<style>" height: 100%;
" body, html {" margin: 0px;
" height: 100%;" }
" margin: 0px;" #spacer {
" }" height: 1000px;
" #spacer {" }
" height: 1000px;" #container {
" }" position: absolute;
" #container {" width: 100%;
" position: absolute;" height: 100%;
" width: 100%;" overflow: auto;
" height: 100%;" }
" overflow: auto;" #target {
" }" width: 100%;
" #target {" height: 50px;
" width: 100%;" }
" height: 50px;" </style>
" }" <div id='container'>
"</style>" <div id='spacer'></div>
"<div id='container'>" <div id='target'></div>
" <div id='spacer'></div>" </div>
" <div id='target'></div>" )HTML");
"</div>",
baseURL);
Document* document = MainFrame()->GetDocument(); Element* container = GetDocument().getElementById("container");
Element* container = document->getElementById("container"); Element* target = GetDocument().getElementById("target");
Element* target = document->getElementById("target"); GetDocument().setRootScroller(container, ASSERT_NO_EXCEPTION);
SetAndSelectRootScroller(*document, container);
Compositor().BeginFrame();
// This test checks hit testing while the target is in the same PaintLayer as // This test checks hit testing while the target is in the same PaintLayer as
// the root scroller. // the root scroller.
...@@ -2557,43 +2568,47 @@ TEST_F(RootScrollerHitTest, DISABLED_HitTestInAreaRevealedByURLBarSameLayer) { ...@@ -2557,43 +2568,47 @@ TEST_F(RootScrollerHitTest, DISABLED_HitTestInAreaRevealedByURLBarSameLayer) {
// revealed by hiding the URL bar works properly when using a root scroller // revealed by hiding the URL bar works properly when using a root scroller
// when the target and scroller are in different PaintLayers. // when the target and scroller are in different PaintLayers.
TEST_F(RootScrollerHitTest, HitTestInAreaRevealedByURLBarDifferentLayer) { TEST_F(RootScrollerHitTest, HitTestInAreaRevealedByURLBarDifferentLayer) {
WebView().ResizeWithBrowserControls(IntSize(400, 400), 50, 0, true);
GetBrowserControls().SetShownRatio(1);
SimRequest request("https://example.com/test.html", "text/html");
LoadURL("https://example.com/test.html");
// Add a target at the bottom of the root scroller that's the size of the url // Add a target at the bottom of the root scroller that's the size of the url
// bar. We'll test that hiding the URL bar appropriately adjusts clipping so // bar. We'll test that hiding the URL bar appropriately adjusts clipping so
// that we can hit this target. // that we can hit this target.
Initialize(); request.Complete(R"HTML(
WebURL baseURL = URLTestHelpers::ToKURL("http://www.test.com/"); <!DOCTYPE html>
FrameTestHelpers::LoadHTMLString(GetWebView()->MainFrameImpl(), <style>
"<!DOCTYPE html>" body, html {
"<style>" height: 100%;
" body, html {" margin: 0px;
" height: 100%;" }
" margin: 0px;" #spacer {
" }" height: 1000px;
" #spacer {" }
" height: 1000px;" #container {
" }" position: absolute;
" #container {" width: 100%;
" position: absolute;" height: 100%;
" width: 100%;" overflow: auto;
" height: 100%;" }
" overflow: auto;" #target {
" }" width: 100%;
" #target {" height: 50px;
" width: 100%;" will-change: transform;
" height: 50px;" }
" will-change: transform;" </style>
" }" <div id='container'>
"</style>" <div id='spacer'></div>
"<div id='container'>" <div id='target'></div>
" <div id='spacer'></div>" </div>
" <div id='target'></div>" )HTML");
"</div>",
baseURL);
Document* document = MainFrame()->GetDocument(); Element* container = GetDocument().getElementById("container");
Element* container = document->getElementById("container"); Element* target = GetDocument().getElementById("target");
Element* target = document->getElementById("target"); GetDocument().setRootScroller(container, ASSERT_NO_EXCEPTION);
SetAndSelectRootScroller(*document, container);
Compositor().BeginFrame();
// Ensure the target and container weren't put into the same layer. // Ensure the target and container weren't put into the same layer.
ASSERT_NE(ToLayoutBox(target->GetLayoutObject())->EnclosingLayer(), ASSERT_NE(ToLayoutBox(target->GetLayoutObject())->EnclosingLayer(),
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment