OLD | NEW |
---|---|
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 2458 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2469 new ContentsZoomChangedDelegate()); | 2469 new ContentsZoomChangedDelegate()); |
2470 contents()->SetDelegate(delegate.get()); | 2470 contents()->SetDelegate(delegate.get()); |
2471 | 2471 |
2472 int modifiers = 0; | 2472 int modifiers = 0; |
2473 // Verify that normal mouse wheel events do nothing to change the zoom level. | 2473 // Verify that normal mouse wheel events do nothing to change the zoom level. |
2474 blink::WebMouseWheelEvent event = | 2474 blink::WebMouseWheelEvent event = |
2475 SyntheticWebMouseWheelEventBuilder::Build(0, 1, modifiers, false); | 2475 SyntheticWebMouseWheelEventBuilder::Build(0, 1, modifiers, false); |
2476 EXPECT_FALSE(contents()->HandleWheelEvent(event)); | 2476 EXPECT_FALSE(contents()->HandleWheelEvent(event)); |
2477 EXPECT_EQ(0, delegate->GetAndResetContentsZoomChangedCallCount()); | 2477 EXPECT_EQ(0, delegate->GetAndResetContentsZoomChangedCallCount()); |
2478 | 2478 |
2479 modifiers = WebInputEvent::ShiftKey | WebInputEvent::AltKey; | 2479 modifiers = WebInputEvent::ShiftKey | WebInputEvent::AltKey; |
Rick Byers
2014/12/18 15:18:14
nit: set the Ctrl modifier here too (to verify tha
lanwei
2014/12/19 02:55:44
Done.
| |
2480 event = SyntheticWebMouseWheelEventBuilder::Build(0, 1, modifiers, false); | 2480 event = SyntheticWebMouseWheelEventBuilder::Build(0, 1, modifiers, false); |
2481 EXPECT_FALSE(contents()->HandleWheelEvent(event)); | 2481 EXPECT_FALSE(contents()->HandleWheelEvent(event)); |
2482 EXPECT_EQ(0, delegate->GetAndResetContentsZoomChangedCallCount()); | 2482 EXPECT_EQ(0, delegate->GetAndResetContentsZoomChangedCallCount()); |
2483 | 2483 |
2484 // But whenever the ctrl modifier is applied, they can increase/decrease zoom. | 2484 // But whenever the ctrl modifier is applied, they can increase/decrease zoom. |
Rick Byers
2014/12/18 15:18:14
nit: add "with canScroll=false" to this comment.
lanwei
2014/12/19 02:55:44
Done.
| |
2485 // Except on MacOS where we never want to adjust zoom with mousewheel. | 2485 // Except on MacOS where we never want to adjust zoom with mousewheel. |
2486 modifiers = WebInputEvent::ControlKey; | 2486 modifiers = WebInputEvent::ControlKey; |
2487 event = SyntheticWebMouseWheelEventBuilder::Build(0, 1, modifiers, false); | 2487 event = SyntheticWebMouseWheelEventBuilder::Build(0, 1, modifiers, false); |
2488 event.canScroll = false; | |
2488 bool handled = contents()->HandleWheelEvent(event); | 2489 bool handled = contents()->HandleWheelEvent(event); |
2489 #if defined(OS_MACOSX) | 2490 #if defined(OS_MACOSX) |
2490 EXPECT_FALSE(handled); | 2491 EXPECT_FALSE(handled); |
2491 EXPECT_EQ(0, delegate->GetAndResetContentsZoomChangedCallCount()); | 2492 EXPECT_EQ(0, delegate->GetAndResetContentsZoomChangedCallCount()); |
2492 #else | 2493 #else |
2493 EXPECT_TRUE(handled); | 2494 EXPECT_TRUE(handled); |
2494 EXPECT_EQ(1, delegate->GetAndResetContentsZoomChangedCallCount()); | 2495 EXPECT_EQ(1, delegate->GetAndResetContentsZoomChangedCallCount()); |
2495 EXPECT_TRUE(delegate->last_zoom_in()); | 2496 EXPECT_TRUE(delegate->last_zoom_in()); |
2496 #endif | 2497 #endif |
2497 | 2498 |
2498 modifiers = WebInputEvent::ControlKey | WebInputEvent::ShiftKey | | 2499 modifiers = WebInputEvent::ControlKey | WebInputEvent::ShiftKey | |
2499 WebInputEvent::AltKey; | 2500 WebInputEvent::AltKey; |
2500 event = SyntheticWebMouseWheelEventBuilder::Build(2, -5, modifiers, false); | 2501 event = SyntheticWebMouseWheelEventBuilder::Build(2, -5, modifiers, false); |
2502 event.canScroll = false; | |
2501 handled = contents()->HandleWheelEvent(event); | 2503 handled = contents()->HandleWheelEvent(event); |
2502 #if defined(OS_MACOSX) | 2504 #if defined(OS_MACOSX) |
2503 EXPECT_FALSE(handled); | 2505 EXPECT_FALSE(handled); |
2504 EXPECT_EQ(0, delegate->GetAndResetContentsZoomChangedCallCount()); | 2506 EXPECT_EQ(0, delegate->GetAndResetContentsZoomChangedCallCount()); |
2505 #else | 2507 #else |
2506 EXPECT_TRUE(handled); | 2508 EXPECT_TRUE(handled); |
2507 EXPECT_EQ(1, delegate->GetAndResetContentsZoomChangedCallCount()); | 2509 EXPECT_EQ(1, delegate->GetAndResetContentsZoomChangedCallCount()); |
2508 EXPECT_FALSE(delegate->last_zoom_in()); | 2510 EXPECT_FALSE(delegate->last_zoom_in()); |
2509 #endif | 2511 #endif |
2510 | 2512 |
(...skipping 274 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2785 | 2787 |
2786 // Destroy the remote player. No power save blockers should remain. | 2788 // Destroy the remote player. No power save blockers should remain. |
2787 rfh->OnMessageReceived( | 2789 rfh->OnMessageReceived( |
2788 FrameHostMsg_MediaPausedNotification(0, kPlayerRemoteId)); | 2790 FrameHostMsg_MediaPausedNotification(0, kPlayerRemoteId)); |
2789 EXPECT_FALSE(contents()->has_video_power_save_blocker_for_testing()); | 2791 EXPECT_FALSE(contents()->has_video_power_save_blocker_for_testing()); |
2790 EXPECT_FALSE(contents()->has_audio_power_save_blocker_for_testing()); | 2792 EXPECT_FALSE(contents()->has_audio_power_save_blocker_for_testing()); |
2791 } | 2793 } |
2792 #endif | 2794 #endif |
2793 | 2795 |
2794 } // namespace content | 2796 } // namespace content |
OLD | NEW |