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

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

Issue 739013008: Explicitly suppress scrolling for wheel events that will trigger zooming (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Modify event_sender.cc Created 5 years, 11 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 "base/logging.h" 5 #include "base/logging.h"
6 #include "base/strings/utf_string_conversions.h" 6 #include "base/strings/utf_string_conversions.h"
7 #include "content/browser/frame_host/cross_site_transferring_request.h" 7 #include "content/browser/frame_host/cross_site_transferring_request.h"
8 #include "content/browser/frame_host/interstitial_page_impl.h" 8 #include "content/browser/frame_host/interstitial_page_impl.h"
9 #include "content/browser/frame_host/navigation_entry_impl.h" 9 #include "content/browser/frame_host/navigation_entry_impl.h"
10 #include "content/browser/media/audio_stream_monitor.h" 10 #include "content/browser/media/audio_stream_monitor.h"
(...skipping 2459 matching lines...) Expand 10 before | Expand all | Expand 10 after
2470 new ContentsZoomChangedDelegate()); 2470 new ContentsZoomChangedDelegate());
2471 contents()->SetDelegate(delegate.get()); 2471 contents()->SetDelegate(delegate.get());
2472 2472
2473 int modifiers = 0; 2473 int modifiers = 0;
2474 // Verify that normal mouse wheel events do nothing to change the zoom level. 2474 // Verify that normal mouse wheel events do nothing to change the zoom level.
2475 blink::WebMouseWheelEvent event = 2475 blink::WebMouseWheelEvent event =
2476 SyntheticWebMouseWheelEventBuilder::Build(0, 1, modifiers, false); 2476 SyntheticWebMouseWheelEventBuilder::Build(0, 1, modifiers, false);
2477 EXPECT_FALSE(contents()->HandleWheelEvent(event)); 2477 EXPECT_FALSE(contents()->HandleWheelEvent(event));
2478 EXPECT_EQ(0, delegate->GetAndResetContentsZoomChangedCallCount()); 2478 EXPECT_EQ(0, delegate->GetAndResetContentsZoomChangedCallCount());
2479 2479
2480 modifiers = WebInputEvent::ShiftKey | WebInputEvent::AltKey; 2480 modifiers = WebInputEvent::ShiftKey | WebInputEvent::AltKey |
2481 WebInputEvent::ControlKey;
2481 event = SyntheticWebMouseWheelEventBuilder::Build(0, 1, modifiers, false); 2482 event = SyntheticWebMouseWheelEventBuilder::Build(0, 1, modifiers, false);
2482 EXPECT_FALSE(contents()->HandleWheelEvent(event)); 2483 EXPECT_FALSE(contents()->HandleWheelEvent(event));
2483 EXPECT_EQ(0, delegate->GetAndResetContentsZoomChangedCallCount()); 2484 EXPECT_EQ(0, delegate->GetAndResetContentsZoomChangedCallCount());
2484 2485
2485 // But whenever the ctrl modifier is applied, they can increase/decrease zoom. 2486 // But whenever the ctrl modifier is applied with canScroll=false, they can
2486 // Except on MacOS where we never want to adjust zoom with mousewheel. 2487 // increase/decrease zoom. Except on MacOS where we never want to adjust zoom
2488 // with mousewheel.
2487 modifiers = WebInputEvent::ControlKey; 2489 modifiers = WebInputEvent::ControlKey;
2488 event = SyntheticWebMouseWheelEventBuilder::Build(0, 1, modifiers, false); 2490 event = SyntheticWebMouseWheelEventBuilder::Build(0, 1, modifiers, false);
2491 event.canScroll = false;
2489 bool handled = contents()->HandleWheelEvent(event); 2492 bool handled = contents()->HandleWheelEvent(event);
2490 #if defined(OS_MACOSX) 2493 #if defined(OS_MACOSX)
2491 EXPECT_FALSE(handled); 2494 EXPECT_FALSE(handled);
2492 EXPECT_EQ(0, delegate->GetAndResetContentsZoomChangedCallCount()); 2495 EXPECT_EQ(0, delegate->GetAndResetContentsZoomChangedCallCount());
2493 #else 2496 #else
2494 EXPECT_TRUE(handled); 2497 EXPECT_TRUE(handled);
2495 EXPECT_EQ(1, delegate->GetAndResetContentsZoomChangedCallCount()); 2498 EXPECT_EQ(1, delegate->GetAndResetContentsZoomChangedCallCount());
2496 EXPECT_TRUE(delegate->last_zoom_in()); 2499 EXPECT_TRUE(delegate->last_zoom_in());
2497 #endif 2500 #endif
2498 2501
2499 modifiers = WebInputEvent::ControlKey | WebInputEvent::ShiftKey | 2502 modifiers = WebInputEvent::ControlKey | WebInputEvent::ShiftKey |
2500 WebInputEvent::AltKey; 2503 WebInputEvent::AltKey;
2501 event = SyntheticWebMouseWheelEventBuilder::Build(2, -5, modifiers, false); 2504 event = SyntheticWebMouseWheelEventBuilder::Build(2, -5, modifiers, false);
2505 event.canScroll = false;
2502 handled = contents()->HandleWheelEvent(event); 2506 handled = contents()->HandleWheelEvent(event);
2503 #if defined(OS_MACOSX) 2507 #if defined(OS_MACOSX)
2504 EXPECT_FALSE(handled); 2508 EXPECT_FALSE(handled);
2505 EXPECT_EQ(0, delegate->GetAndResetContentsZoomChangedCallCount()); 2509 EXPECT_EQ(0, delegate->GetAndResetContentsZoomChangedCallCount());
2506 #else 2510 #else
2507 EXPECT_TRUE(handled); 2511 EXPECT_TRUE(handled);
2508 EXPECT_EQ(1, delegate->GetAndResetContentsZoomChangedCallCount()); 2512 EXPECT_EQ(1, delegate->GetAndResetContentsZoomChangedCallCount());
2509 EXPECT_FALSE(delegate->last_zoom_in()); 2513 EXPECT_FALSE(delegate->last_zoom_in());
2510 #endif 2514 #endif
2511 2515
(...skipping 274 matching lines...) Expand 10 before | Expand all | Expand 10 after
2786 2790
2787 // Destroy the remote player. No power save blockers should remain. 2791 // Destroy the remote player. No power save blockers should remain.
2788 rfh->OnMessageReceived( 2792 rfh->OnMessageReceived(
2789 FrameHostMsg_MediaPausedNotification(0, kPlayerRemoteId)); 2793 FrameHostMsg_MediaPausedNotification(0, kPlayerRemoteId));
2790 EXPECT_FALSE(contents()->has_video_power_save_blocker_for_testing()); 2794 EXPECT_FALSE(contents()->has_video_power_save_blocker_for_testing());
2791 EXPECT_FALSE(contents()->has_audio_power_save_blocker_for_testing()); 2795 EXPECT_FALSE(contents()->has_audio_power_save_blocker_for_testing());
2792 } 2796 }
2793 #endif 2797 #endif
2794 2798
2795 } // namespace content 2799 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/web_contents/web_contents_impl.cc ('k') | content/common/input/synthetic_web_input_event_builders.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698