| OLD | NEW |
| 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 157 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 168 EmulateMouseDrag(left_point_in_link_, right_point_in_link_, | 168 EmulateMouseDrag(left_point_in_link_, right_point_in_link_, |
| 169 WebInputEvent::kAltKey); | 169 WebInputEvent::kAltKey); |
| 170 EXPECT_EQ("to select", GetSelectionText()); | 170 EXPECT_EQ("to select", GetSelectionText()); |
| 171 } | 171 } |
| 172 | 172 |
| 173 TEST_F(LinkSelectionTest, HandCursorDuringLinkDrag) { | 173 TEST_F(LinkSelectionTest, HandCursorDuringLinkDrag) { |
| 174 EmulateMouseDrag(right_point_in_link_, left_point_in_link_, 0, | 174 EmulateMouseDrag(right_point_in_link_, left_point_in_link_, 0, |
| 175 kSendDownEvent); | 175 kSendDownEvent); |
| 176 main_frame_->GetFrame() | 176 main_frame_->GetFrame() |
| 177 ->LocalFrameRoot() | 177 ->LocalFrameRoot() |
| 178 ->GetEventHandler() | 178 .GetEventHandler() |
| 179 .ScheduleCursorUpdate(); | 179 .ScheduleCursorUpdate(); |
| 180 testing::RunDelayedTasks(50); | 180 testing::RunDelayedTasks(50); |
| 181 const auto& cursor = | 181 const auto& cursor = |
| 182 main_frame_->GetFrame()->GetChromeClient().LastSetCursorForTesting(); | 182 main_frame_->GetFrame()->GetChromeClient().LastSetCursorForTesting(); |
| 183 EXPECT_EQ(Cursor::kHand, cursor.GetType()); | 183 EXPECT_EQ(Cursor::kHand, cursor.GetType()); |
| 184 } | 184 } |
| 185 | 185 |
| 186 TEST_F(LinkSelectionTest, CaretCursorOverLinkDuringSelection) { | 186 TEST_F(LinkSelectionTest, CaretCursorOverLinkDuringSelection) { |
| 187 EmulateMouseDrag(right_point_in_link_, left_point_in_link_, | 187 EmulateMouseDrag(right_point_in_link_, left_point_in_link_, |
| 188 WebInputEvent::kAltKey, kSendDownEvent); | 188 WebInputEvent::kAltKey, kSendDownEvent); |
| 189 main_frame_->GetFrame() | 189 main_frame_->GetFrame() |
| 190 ->LocalFrameRoot() | 190 ->LocalFrameRoot() |
| 191 ->GetEventHandler() | 191 .GetEventHandler() |
| 192 .ScheduleCursorUpdate(); | 192 .ScheduleCursorUpdate(); |
| 193 testing::RunDelayedTasks(50); | 193 testing::RunDelayedTasks(50); |
| 194 const auto& cursor = | 194 const auto& cursor = |
| 195 main_frame_->GetFrame()->GetChromeClient().LastSetCursorForTesting(); | 195 main_frame_->GetFrame()->GetChromeClient().LastSetCursorForTesting(); |
| 196 EXPECT_EQ(Cursor::kIBeam, cursor.GetType()); | 196 EXPECT_EQ(Cursor::kIBeam, cursor.GetType()); |
| 197 } | 197 } |
| 198 | 198 |
| 199 TEST_F(LinkSelectionTest, HandCursorOverLinkAfterContextMenu) { | 199 TEST_F(LinkSelectionTest, HandCursorOverLinkAfterContextMenu) { |
| 200 // Move mouse. | 200 // Move mouse. |
| 201 EmulateMouseDrag(right_point_in_link_, left_point_in_link_, 0, 0); | 201 EmulateMouseDrag(right_point_in_link_, left_point_in_link_, 0, 0); |
| 202 | 202 |
| 203 // Show context menu. We don't send mouseup event here since in browser it | 203 // Show context menu. We don't send mouseup event here since in browser it |
| 204 // doesn't reach blink because of shown context menu. | 204 // doesn't reach blink because of shown context menu. |
| 205 EmulateMouseDown(left_point_in_link_, WebMouseEvent::Button::kRight, 0, 1); | 205 EmulateMouseDown(left_point_in_link_, WebMouseEvent::Button::kRight, 0, 1); |
| 206 | 206 |
| 207 LocalFrame* frame = main_frame_->GetFrame(); | 207 LocalFrame* frame = main_frame_->GetFrame(); |
| 208 // Hide context menu. | 208 // Hide context menu. |
| 209 frame->GetPage()->GetContextMenuController().ClearContextMenu(); | 209 frame->GetPage()->GetContextMenuController().ClearContextMenu(); |
| 210 | 210 |
| 211 frame->LocalFrameRoot()->GetEventHandler().ScheduleCursorUpdate(); | 211 frame->LocalFrameRoot().GetEventHandler().ScheduleCursorUpdate(); |
| 212 testing::RunDelayedTasks(50); | 212 testing::RunDelayedTasks(50); |
| 213 const auto& cursor = | 213 const auto& cursor = |
| 214 main_frame_->GetFrame()->GetChromeClient().LastSetCursorForTesting(); | 214 main_frame_->GetFrame()->GetChromeClient().LastSetCursorForTesting(); |
| 215 EXPECT_EQ(Cursor::kHand, cursor.GetType()); | 215 EXPECT_EQ(Cursor::kHand, cursor.GetType()); |
| 216 } | 216 } |
| 217 | 217 |
| 218 TEST_F(LinkSelectionTest, SingleClickWithAltStartsDownload) { | 218 TEST_F(LinkSelectionTest, SingleClickWithAltStartsDownload) { |
| 219 EXPECT_CALL( | 219 EXPECT_CALL( |
| 220 test_frame_client_, | 220 test_frame_client_, |
| 221 LoadURLExternally(_, WebNavigationPolicy::kWebNavigationPolicyDownload, | 221 LoadURLExternally(_, WebNavigationPolicy::kWebNavigationPolicyDownload, |
| (...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 331 CheckMouseClicks(*element, false); | 331 CheckMouseClicks(*element, false); |
| 332 } | 332 } |
| 333 | 333 |
| 334 { | 334 { |
| 335 SCOPED_TRACE("Text div, double click"); | 335 SCOPED_TRACE("Text div, double click"); |
| 336 CheckMouseClicks(*element, true); | 336 CheckMouseClicks(*element, true); |
| 337 } | 337 } |
| 338 } | 338 } |
| 339 | 339 |
| 340 } // namespace blink | 340 } // namespace blink |
| OLD | NEW |