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

Side by Side Diff: third_party/WebKit/Source/web/tests/LinkSelectionTest.cpp

Issue 2384033002: reflow comments in web/tests (Closed)
Patch Set: comments (heh!) Created 4 years, 2 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 (c) 2016 The Chromium Authors. All rights reserved. 1 // Copyright (c) 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 "core/dom/Range.h" 5 #include "core/dom/Range.h"
6 #include "core/frame/FrameView.h" 6 #include "core/frame/FrameView.h"
7 #include "core/input/EventHandler.h" 7 #include "core/input/EventHandler.h"
8 #include "core/page/ChromeClient.h" 8 #include "core/page/ChromeClient.h"
9 #include "core/page/ContextMenuController.h" 9 #include "core/page/ContextMenuController.h"
10 #include "core/page/FocusController.h" 10 #include "core/page/FocusController.h"
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after
120 }; 120 };
121 121
122 class LinkSelectionTest : public LinkSelectionTestBase { 122 class LinkSelectionTest : public LinkSelectionTestBase {
123 protected: 123 protected:
124 void SetUp() override { 124 void SetUp() override {
125 const char* const kHTMLString = 125 const char* const kHTMLString =
126 "<a id='link' href='foo.com' style='font-size:20pt'>Text to select " 126 "<a id='link' href='foo.com' style='font-size:20pt'>Text to select "
127 "foobar</a>" 127 "foobar</a>"
128 "<div id='page_text'>Lorem ipsum dolor sit amet</div>"; 128 "<div id='page_text'>Lorem ipsum dolor sit amet</div>";
129 129
130 // We need to set deviceSupportsMouse setting to true and page's focus contr oller to active 130 // We need to set deviceSupportsMouse setting to true and page's focus
131 // so that FrameView can set the mouse cursor. 131 // controller to active so that FrameView can set the mouse cursor.
132 m_webView = m_helper.initialize( 132 m_webView = m_helper.initialize(
133 false, &m_testFrameClient, nullptr, nullptr, 133 false, &m_testFrameClient, nullptr, nullptr,
134 [](WebSettings* settings) { settings->setDeviceSupportsMouse(true); }); 134 [](WebSettings* settings) { settings->setDeviceSupportsMouse(true); });
135 m_mainFrame = m_webView->mainFrameImpl(); 135 m_mainFrame = m_webView->mainFrameImpl();
136 FrameTestHelpers::loadHTMLString( 136 FrameTestHelpers::loadHTMLString(
137 m_mainFrame, kHTMLString, URLTestHelpers::toKURL("http://foobar.com")); 137 m_mainFrame, kHTMLString, URLTestHelpers::toKURL("http://foobar.com"));
138 m_webView->resize(WebSize(800, 600)); 138 m_webView->resize(WebSize(800, 600));
139 m_webView->page()->focusController().setActive(true); 139 m_webView->page()->focusController().setActive(true);
140 140
141 auto* document = m_mainFrame->frame()->document(); 141 auto* document = m_mainFrame->frame()->document();
142 ASSERT_NE(nullptr, document); 142 ASSERT_NE(nullptr, document);
143 auto* linkToSelect = document->getElementById("link")->firstChild(); 143 auto* linkToSelect = document->getElementById("link")->firstChild();
144 ASSERT_NE(nullptr, linkToSelect); 144 ASSERT_NE(nullptr, linkToSelect);
145 // We get larger range that we actually want to select, because we need a sl ightly larger 145 // We get larger range that we actually want to select, because we need a
146 // rect to include the last character to the selection. 146 // slightly larger rect to include the last character to the selection.
147 const auto rangeToSelect = 147 const auto rangeToSelect =
148 Range::create(*document, linkToSelect, 5, linkToSelect, 16); 148 Range::create(*document, linkToSelect, 5, linkToSelect, 16);
149 149
150 const auto& selectionRect = rangeToSelect->boundingBox(); 150 const auto& selectionRect = rangeToSelect->boundingBox();
151 const auto& selectionRectCenterY = selectionRect.center().y(); 151 const auto& selectionRectCenterY = selectionRect.center().y();
152 m_leftPointInLink = selectionRect.minXMinYCorner(); 152 m_leftPointInLink = selectionRect.minXMinYCorner();
153 m_leftPointInLink.setY(selectionRectCenterY); 153 m_leftPointInLink.setY(selectionRectCenterY);
154 154
155 m_rightPointInLink = selectionRect.maxXMinYCorner(); 155 m_rightPointInLink = selectionRect.maxXMinYCorner();
156 m_rightPointInLink.setY(selectionRectCenterY); 156 m_rightPointInLink.setY(selectionRectCenterY);
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
189 testing::runDelayedTasks(50); 189 testing::runDelayedTasks(50);
190 const auto& cursor = 190 const auto& cursor =
191 m_mainFrame->frame()->chromeClient().lastSetCursorForTesting(); 191 m_mainFrame->frame()->chromeClient().lastSetCursorForTesting();
192 EXPECT_EQ(Cursor::IBeam, cursor.getType()); 192 EXPECT_EQ(Cursor::IBeam, cursor.getType());
193 } 193 }
194 194
195 TEST_F(LinkSelectionTest, HandCursorOverLinkAfterContextMenu) { 195 TEST_F(LinkSelectionTest, HandCursorOverLinkAfterContextMenu) {
196 // Move mouse. 196 // Move mouse.
197 emulateMouseDrag(m_rightPointInLink, m_leftPointInLink, 0, 0); 197 emulateMouseDrag(m_rightPointInLink, m_leftPointInLink, 0, 0);
198 198
199 // Show context menu. We don't send mouseup event here since in browser it doe sn't reach 199 // Show context menu. We don't send mouseup event here since in browser it
200 // blink because of shown context menu. 200 // doesn't reach blink because of shown context menu.
201 emulateMouseDown(m_leftPointInLink, WebMouseEvent::Button::Right, 0, 1); 201 emulateMouseDown(m_leftPointInLink, WebMouseEvent::Button::Right, 0, 1);
202 202
203 LocalFrame* frame = m_mainFrame->frame(); 203 LocalFrame* frame = m_mainFrame->frame();
204 // Hide context menu. 204 // Hide context menu.
205 frame->page()->contextMenuController().clearContextMenu(); 205 frame->page()->contextMenuController().clearContextMenu();
206 206
207 frame->localFrameRoot()->eventHandler().scheduleCursorUpdate(); 207 frame->localFrameRoot()->eventHandler().scheduleCursorUpdate();
208 testing::runDelayedTasks(50); 208 testing::runDelayedTasks(50);
209 const auto& cursor = 209 const auto& cursor =
210 m_mainFrame->frame()->chromeClient().lastSetCursorForTesting(); 210 m_mainFrame->frame()->chromeClient().lastSetCursorForTesting();
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after
327 checkMouseClicks(*element, false); 327 checkMouseClicks(*element, false);
328 } 328 }
329 329
330 { 330 {
331 SCOPED_TRACE("Text div, double click"); 331 SCOPED_TRACE("Text div, double click");
332 checkMouseClicks(*element, true); 332 checkMouseClicks(*element, true);
333 } 333 }
334 } 334 }
335 335
336 } // namespace blink 336 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/web/tests/LayoutGeometryMapTest.cpp ('k') | third_party/WebKit/Source/web/tests/MHTMLTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698