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

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

Issue 1865813002: Remove RawPtr from Source/web/ (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebased Created 4 years, 8 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 182 matching lines...) Expand 10 before | Expand all | Expand 10 after
193 emulateMouseClick(m_leftPointInLink, WebMouseEvent::ButtonLeft, WebInputEven t::AltKey); 193 emulateMouseClick(m_leftPointInLink, WebMouseEvent::ButtonLeft, WebInputEven t::AltKey);
194 } 194 }
195 195
196 TEST_F(LinkSelectionTest, SingleClickWithAltStartsDownloadWhenTextSelected) 196 TEST_F(LinkSelectionTest, SingleClickWithAltStartsDownloadWhenTextSelected)
197 { 197 {
198 auto* document = m_mainFrame->frame()->document(); 198 auto* document = m_mainFrame->frame()->document();
199 auto* textToSelect = document->getElementById("page_text")->firstChild(); 199 auto* textToSelect = document->getElementById("page_text")->firstChild();
200 ASSERT_NE(nullptr, textToSelect); 200 ASSERT_NE(nullptr, textToSelect);
201 201
202 // Select some page text outside the link element. 202 // Select some page text outside the link element.
203 const RawPtr<Range> rangeToSelect = Range::create(*document, textToSelect, 1 , textToSelect, 20); 203 const Range* rangeToSelect = Range::create(*document, textToSelect, 1, textT oSelect, 20);
204 const auto& selectionRect = rangeToSelect->boundingBox(); 204 const auto& selectionRect = rangeToSelect->boundingBox();
205 m_mainFrame->moveRangeSelection(selectionRect.minXMinYCorner(), selectionRec t.maxXMaxYCorner()); 205 m_mainFrame->moveRangeSelection(selectionRect.minXMinYCorner(), selectionRec t.maxXMaxYCorner());
206 EXPECT_FALSE(getSelectionText().isEmpty()); 206 EXPECT_FALSE(getSelectionText().isEmpty());
207 207
208 EXPECT_CALL(m_testFrameClient, loadURLExternally(_, WebNavigationPolicy::Web NavigationPolicyDownload, WebString(), _)); 208 EXPECT_CALL(m_testFrameClient, loadURLExternally(_, WebNavigationPolicy::Web NavigationPolicyDownload, WebString(), _));
209 emulateMouseClick(m_leftPointInLink, WebMouseEvent::ButtonLeft, WebInputEven t::AltKey); 209 emulateMouseClick(m_leftPointInLink, WebMouseEvent::ButtonLeft, WebInputEven t::AltKey);
210 } 210 }
211 211
212 class LinkSelectionClickEventsTest : public LinkSelectionTestBase { 212 class LinkSelectionClickEventsTest : public LinkSelectionTestBase {
213 protected: 213 protected:
214 class MockEventListener final : public EventListener { 214 class MockEventListener final : public EventListener {
215 public: 215 public:
216 static RawPtr<MockEventListener> create() 216 static MockEventListener* create()
217 { 217 {
218 return new MockEventListener(); 218 return new MockEventListener();
219 } 219 }
220 220
221 bool operator==(const EventListener& other) const final 221 bool operator==(const EventListener& other) const final
222 { 222 {
223 return this == &other; 223 return this == &other;
224 } 224 }
225 225
226 MOCK_METHOD2(handleEvent, void(ExecutionContext* executionContext, Event *)); 226 MOCK_METHOD2(handleEvent, void(ExecutionContext* executionContext, Event *));
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
258 ScopedListenersCleaner(Element* element) : m_element(element) {} 258 ScopedListenersCleaner(Element* element) : m_element(element) {}
259 259
260 ~ScopedListenersCleaner() 260 ~ScopedListenersCleaner()
261 { 261 {
262 m_element->removeAllEventListeners(); 262 m_element->removeAllEventListeners();
263 } 263 }
264 264
265 Persistent<Element> m_element; 265 Persistent<Element> m_element;
266 } const listenersCleaner(&element); 266 } const listenersCleaner(&element);
267 267
268 RawPtr<MockEventListener> eventHandler = MockEventListener::create(); 268 MockEventListener* eventHandler = MockEventListener::create();
269 element.addEventListener( 269 element.addEventListener(
270 doubleClickEvent ? EventTypeNames::dblclick : EventTypeNames::click, 270 doubleClickEvent ? EventTypeNames::dblclick : EventTypeNames::click,
271 eventHandler); 271 eventHandler);
272 272
273 ::testing::InSequence s; 273 ::testing::InSequence s;
274 EXPECT_CALL(*eventHandler, handleEvent(_, _)).Times(1); 274 EXPECT_CALL(*eventHandler, handleEvent(_, _)).Times(1);
275 275
276 const auto& elemBounds = element.boundsInViewport(); 276 const auto& elemBounds = element.boundsInViewport();
277 const int clickCount = doubleClickEvent ? 2 : 1; 277 const int clickCount = doubleClickEvent ? 2 : 1;
278 emulateMouseClick(elemBounds.center(), WebMouseEvent::ButtonLeft, 0, cli ckCount); 278 emulateMouseClick(elemBounds.center(), WebMouseEvent::ButtonLeft, 0, cli ckCount);
(...skipping 26 matching lines...) Expand all
305 checkMouseClicks(*element, false); 305 checkMouseClicks(*element, false);
306 } 306 }
307 307
308 { 308 {
309 SCOPED_TRACE("Text div, double click"); 309 SCOPED_TRACE("Text div, double click");
310 checkMouseClicks(*element, true); 310 checkMouseClicks(*element, true);
311 } 311 }
312 } 312 }
313 313
314 } // namespace blink 314 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/web/tests/KeyboardTest.cpp ('k') | third_party/WebKit/Source/web/tests/TextFinderTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698