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

Side by Side Diff: content/browser/web_contents/web_contents_view_aura_browsertest.cc

Issue 2933353003: Mark the ET_MOUSE_MOVED created from a pointer grab as synthesized. (Closed)
Patch Set: Clarify comment. Created 3 years, 5 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) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 "content/browser/web_contents/web_contents_view_aura.h" 5 #include "content/browser/web_contents/web_contents_view_aura.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 #include <tuple> 8 #include <tuple>
9 9
10 #include "base/command_line.h" 10 #include "base/command_line.h"
(...skipping 10 matching lines...) Expand all
21 #include "content/browser/frame_host/navigation_controller_impl.h" 21 #include "content/browser/frame_host/navigation_controller_impl.h"
22 #include "content/browser/frame_host/navigation_entry_impl.h" 22 #include "content/browser/frame_host/navigation_entry_impl.h"
23 #include "content/browser/frame_host/navigation_entry_screenshot_manager.h" 23 #include "content/browser/frame_host/navigation_entry_screenshot_manager.h"
24 #include "content/browser/renderer_host/render_widget_host_view_aura.h" 24 #include "content/browser/renderer_host/render_widget_host_view_aura.h"
25 #include "content/browser/web_contents/web_contents_impl.h" 25 #include "content/browser/web_contents/web_contents_impl.h"
26 #include "content/browser/web_contents/web_contents_view.h" 26 #include "content/browser/web_contents/web_contents_view.h"
27 #include "content/common/input/synthetic_web_input_event_builders.h" 27 #include "content/common/input/synthetic_web_input_event_builders.h"
28 #include "content/common/input_messages.h" 28 #include "content/common/input_messages.h"
29 #include "content/common/view_messages.h" 29 #include "content/common/view_messages.h"
30 #include "content/public/browser/browser_message_filter.h" 30 #include "content/public/browser/browser_message_filter.h"
31 #include "content/public/browser/overscroll_configuration.h"
31 #include "content/public/browser/render_frame_host.h" 32 #include "content/public/browser/render_frame_host.h"
32 #include "content/public/browser/render_widget_host.h" 33 #include "content/public/browser/render_widget_host.h"
33 #include "content/public/browser/web_contents_delegate.h" 34 #include "content/public/browser/web_contents_delegate.h"
34 #include "content/public/browser/web_contents_observer.h" 35 #include "content/public/browser/web_contents_observer.h"
35 #include "content/public/common/content_switches.h" 36 #include "content/public/common/content_switches.h"
36 #include "content/public/test/browser_test_utils.h" 37 #include "content/public/test/browser_test_utils.h"
37 #include "content/public/test/content_browser_test.h" 38 #include "content/public/test/content_browser_test.h"
38 #include "content/public/test/content_browser_test_utils.h" 39 #include "content/public/test/content_browser_test_utils.h"
39 #include "content/public/test/test_renderer_host.h" 40 #include "content/public/test/test_renderer_host.h"
40 #include "content/public/test/test_utils.h" 41 #include "content/public/test/test_utils.h"
(...skipping 381 matching lines...) Expand 10 before | Expand all | Expand 10 after
422 DISABLED_OverscrollNavigationWithTouchHandler 423 DISABLED_OverscrollNavigationWithTouchHandler
423 #else 424 #else
424 #define MAYBE_OverscrollNavigationWithTouchHandler \ 425 #define MAYBE_OverscrollNavigationWithTouchHandler \
425 OverscrollNavigationWithTouchHandler 426 OverscrollNavigationWithTouchHandler
426 #endif 427 #endif
427 IN_PROC_BROWSER_TEST_F(WebContentsViewAuraTest, 428 IN_PROC_BROWSER_TEST_F(WebContentsViewAuraTest,
428 MAYBE_OverscrollNavigationWithTouchHandler) { 429 MAYBE_OverscrollNavigationWithTouchHandler) {
429 TestOverscrollNavigation(true); 430 TestOverscrollNavigation(true);
430 } 431 }
431 432
433 namespace {
434 // This fails the test if it sees any mouse move events.
435 class SpuriousMouseMoveEventObserver
436 : public RenderWidgetHost::InputEventObserver {
437 public:
438 explicit SpuriousMouseMoveEventObserver(RenderWidgetHost* host)
439 : host_(host) {
440 host_->AddInputEventObserver(this);
441 }
442
443 ~SpuriousMouseMoveEventObserver() override {
444 host_->RemoveInputEventObserver(this);
445 }
446
447 void OnInputEvent(const blink::WebInputEvent& event) override {
448 EXPECT_NE(blink::WebInputEvent::kMouseMove, event.GetType())
449 << "Unexpected mouse move event.";
450 }
451
452 private:
453 RenderWidgetHost* host_;
454
455 DISALLOW_COPY_AND_ASSIGN(SpuriousMouseMoveEventObserver);
456 };
457 } // namespace
458
459 // Start an overscroll gesture and then check if the gesture is interrupted by
460 // a spurious mouse event. Overscrolling may trigger mouse-move events, but
461 // these should all be marked as synthesized and get dropped while the
462 // overscroll gesture is in progress.
463 // See crbug.com/731914
464 IN_PROC_BROWSER_TEST_F(WebContentsViewAuraTest,
465 OverscrollNotInterruptedBySpuriousMouseEvents) {
466 ASSERT_NO_FATAL_FAILURE(StartTestWithPage("/overscroll_navigation.html"));
467 WebContentsImpl* web_contents =
468 static_cast<WebContentsImpl*>(shell()->web_contents());
469 NavigationController& controller = web_contents->GetController();
470 RenderFrameHost* main_frame = web_contents->GetMainFrame();
471
472 EXPECT_FALSE(controller.CanGoBack());
473 EXPECT_FALSE(controller.CanGoForward());
474 int index = -1;
475 std::unique_ptr<base::Value> value =
476 content::ExecuteScriptAndGetValue(main_frame, "get_current()");
477 ASSERT_TRUE(value->GetAsInteger(&index));
478 EXPECT_EQ(0, index);
479
480 ExecuteSyncJSFunction(main_frame, "navigate_next()");
481 value = content::ExecuteScriptAndGetValue(main_frame, "get_current()");
482 ASSERT_TRUE(value->GetAsInteger(&index));
483 EXPECT_EQ(1, index);
484 EXPECT_TRUE(controller.CanGoBack());
485 EXPECT_FALSE(controller.CanGoForward());
486
487 // We start an overscroll gesture, but pause mid-gesture.
488
489 // Fail the test if the following gesture produces mouse-moves that don't get
490 // dropped.
491 SpuriousMouseMoveEventObserver mouse_observer(GetRenderWidgetHost());
492
493 blink::WebGestureEvent gesture_scroll_begin(
494 blink::WebGestureEvent::kGestureScrollBegin,
495 blink::WebInputEvent::kNoModifiers,
496 blink::WebInputEvent::kTimeStampForTesting);
497 gesture_scroll_begin.source_device = blink::kWebGestureDeviceTouchscreen;
498 gesture_scroll_begin.data.scroll_begin.delta_hint_units =
499 blink::WebGestureEvent::ScrollUnits::kPrecisePixels;
500 gesture_scroll_begin.data.scroll_begin.delta_x_hint = 0.f;
501 gesture_scroll_begin.data.scroll_begin.delta_y_hint = 0.f;
502 GetRenderWidgetHost()->ForwardGestureEvent(gesture_scroll_begin);
503
504 blink::WebGestureEvent gesture_scroll_update(
505 blink::WebGestureEvent::kGestureScrollUpdate,
506 blink::WebInputEvent::kNoModifiers,
507 blink::WebInputEvent::kTimeStampForTesting);
508 gesture_scroll_update.source_device = blink::kWebGestureDeviceTouchscreen;
509 gesture_scroll_update.data.scroll_update.delta_units =
510 blink::WebGestureEvent::ScrollUnits::kPrecisePixels;
511 gesture_scroll_update.data.scroll_update.delta_y = 0.f;
512 float horiz_threshold =
513 GetOverscrollConfig(OVERSCROLL_CONFIG_HORIZ_THRESHOLD_START_TOUCHSCREEN);
514 gesture_scroll_update.data.scroll_update.delta_x = horiz_threshold + 1;
515 GetRenderWidgetHost()->ForwardGestureEvent(gesture_scroll_update);
516
517 // Wait for the overscroll gesture to start and then allow some time for the
518 // spurious mouse event. Since we're testing that an event does not happen,
519 // we just have a timeout. This could potentially result in the event
520 // happening after the timeout, which would cause the test to succeed
521 // incorrectly. That said, the event we're worried about happens almost
522 // instantly after the start of the overscroll gesture.
523 base::RunLoop run_loop;
524 base::ThreadTaskRunnerHandle::Get()->PostDelayedTask(
525 FROM_HERE, run_loop.QuitClosure(), TestTimeouts::tiny_timeout());
526 run_loop.Run();
527
528 // Check that the overscroll gesture was not reset.
529 OverscrollController* overscroll_controller =
530 static_cast<RenderWidgetHostViewAura*>(GetRenderWidgetHostView())
531 ->overscroll_controller();
532 EXPECT_NE(OVERSCROLL_NONE, overscroll_controller->overscroll_mode());
533 }
534
432 // Disabled because the test always fails the first time it runs on the Win Aura 535 // Disabled because the test always fails the first time it runs on the Win Aura
433 // bots, and usually but not always passes second-try (See crbug.com/179532). 536 // bots, and usually but not always passes second-try (See crbug.com/179532).
434 // On Linux, the test frequently times out. (See crbug.com/440043). 537 // On Linux, the test frequently times out. (See crbug.com/440043).
435 #if defined(OS_WIN) || defined(OS_LINUX) 538 #if defined(OS_WIN) || defined(OS_LINUX)
436 #define MAYBE_QuickOverscrollDirectionChange \ 539 #define MAYBE_QuickOverscrollDirectionChange \
437 DISABLED_QuickOverscrollDirectionChange 540 DISABLED_QuickOverscrollDirectionChange
438 #else 541 #else
439 #define MAYBE_QuickOverscrollDirectionChange QuickOverscrollDirectionChange 542 #define MAYBE_QuickOverscrollDirectionChange QuickOverscrollDirectionChange
440 #endif 543 #endif
441 IN_PROC_BROWSER_TEST_F(WebContentsViewAuraTest, 544 IN_PROC_BROWSER_TEST_F(WebContentsViewAuraTest,
(...skipping 679 matching lines...) Expand 10 before | Expand all | Expand 10 after
1121 details = sink->OnEventFromSource(&release); 1224 details = sink->OnEventFromSource(&release);
1122 ASSERT_FALSE(details.dispatcher_destroyed); 1225 ASSERT_FALSE(details.dispatcher_destroyed);
1123 WaitAFrame(); 1226 WaitAFrame();
1124 1227
1125 EXPECT_LT(0, tracker.num_overscroll_updates()); 1228 EXPECT_LT(0, tracker.num_overscroll_updates());
1126 EXPECT_FALSE(tracker.overscroll_completed()); 1229 EXPECT_FALSE(tracker.overscroll_completed());
1127 } 1230 }
1128 } 1231 }
1129 1232
1130 } // namespace content 1233 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/renderer_host/render_widget_host_view_event_handler.cc ('k') | ui/aura/env_input_state_controller.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698