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; |
2480 WebInputEvent::ControlKey; | |
2481 event = SyntheticWebMouseWheelEventBuilder::Build(0, 1, modifiers, false); | 2480 event = SyntheticWebMouseWheelEventBuilder::Build(0, 1, modifiers, false); |
2482 EXPECT_FALSE(contents()->HandleWheelEvent(event)); | 2481 EXPECT_FALSE(contents()->HandleWheelEvent(event)); |
2483 EXPECT_EQ(0, delegate->GetAndResetContentsZoomChangedCallCount()); | 2482 EXPECT_EQ(0, delegate->GetAndResetContentsZoomChangedCallCount()); |
2484 | 2483 |
2485 // But whenever the ctrl modifier is applied with canScroll=false, they can | 2484 // But whenever the ctrl modifier is applied, they can increase/decrease zoom. |
2486 // increase/decrease zoom. Except on MacOS where we never want to adjust zoom | 2485 // Except on MacOS where we never want to adjust zoom with mousewheel. |
2487 // with mousewheel. | |
2488 modifiers = WebInputEvent::ControlKey; | 2486 modifiers = WebInputEvent::ControlKey; |
2489 event = SyntheticWebMouseWheelEventBuilder::Build(0, 1, modifiers, false); | 2487 event = SyntheticWebMouseWheelEventBuilder::Build(0, 1, modifiers, false); |
2490 event.canScroll = false; | |
2491 bool handled = contents()->HandleWheelEvent(event); | 2488 bool handled = contents()->HandleWheelEvent(event); |
2492 #if defined(OS_MACOSX) | 2489 #if defined(OS_MACOSX) |
2493 EXPECT_FALSE(handled); | 2490 EXPECT_FALSE(handled); |
2494 EXPECT_EQ(0, delegate->GetAndResetContentsZoomChangedCallCount()); | 2491 EXPECT_EQ(0, delegate->GetAndResetContentsZoomChangedCallCount()); |
2495 #else | 2492 #else |
2496 EXPECT_TRUE(handled); | 2493 EXPECT_TRUE(handled); |
2497 EXPECT_EQ(1, delegate->GetAndResetContentsZoomChangedCallCount()); | 2494 EXPECT_EQ(1, delegate->GetAndResetContentsZoomChangedCallCount()); |
2498 EXPECT_TRUE(delegate->last_zoom_in()); | 2495 EXPECT_TRUE(delegate->last_zoom_in()); |
2499 #endif | 2496 #endif |
2500 | 2497 |
2501 modifiers = WebInputEvent::ControlKey | WebInputEvent::ShiftKey | | 2498 modifiers = WebInputEvent::ControlKey | WebInputEvent::ShiftKey | |
2502 WebInputEvent::AltKey; | 2499 WebInputEvent::AltKey; |
2503 event = SyntheticWebMouseWheelEventBuilder::Build(2, -5, modifiers, false); | 2500 event = SyntheticWebMouseWheelEventBuilder::Build(2, -5, modifiers, false); |
2504 event.canScroll = false; | |
2505 handled = contents()->HandleWheelEvent(event); | 2501 handled = contents()->HandleWheelEvent(event); |
2506 #if defined(OS_MACOSX) | 2502 #if defined(OS_MACOSX) |
2507 EXPECT_FALSE(handled); | 2503 EXPECT_FALSE(handled); |
2508 EXPECT_EQ(0, delegate->GetAndResetContentsZoomChangedCallCount()); | 2504 EXPECT_EQ(0, delegate->GetAndResetContentsZoomChangedCallCount()); |
2509 #else | 2505 #else |
2510 EXPECT_TRUE(handled); | 2506 EXPECT_TRUE(handled); |
2511 EXPECT_EQ(1, delegate->GetAndResetContentsZoomChangedCallCount()); | 2507 EXPECT_EQ(1, delegate->GetAndResetContentsZoomChangedCallCount()); |
2512 EXPECT_FALSE(delegate->last_zoom_in()); | 2508 EXPECT_FALSE(delegate->last_zoom_in()); |
2513 #endif | 2509 #endif |
2514 | 2510 |
(...skipping 274 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2789 | 2785 |
2790 // Destroy the remote player. No power save blockers should remain. | 2786 // Destroy the remote player. No power save blockers should remain. |
2791 rfh->OnMessageReceived( | 2787 rfh->OnMessageReceived( |
2792 FrameHostMsg_MediaPausedNotification(0, kPlayerRemoteId)); | 2788 FrameHostMsg_MediaPausedNotification(0, kPlayerRemoteId)); |
2793 EXPECT_FALSE(contents()->has_video_power_save_blocker_for_testing()); | 2789 EXPECT_FALSE(contents()->has_video_power_save_blocker_for_testing()); |
2794 EXPECT_FALSE(contents()->has_audio_power_save_blocker_for_testing()); | 2790 EXPECT_FALSE(contents()->has_audio_power_save_blocker_for_testing()); |
2795 } | 2791 } |
2796 #endif | 2792 #endif |
2797 | 2793 |
2798 } // namespace content | 2794 } // namespace content |
OLD | NEW |