| 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 "chrome/browser/download/download_browsertest.h" | 5 #include "chrome/browser/download/download_browsertest.h" |
| 6 | 6 |
| 7 #include <stdint.h> | 7 #include <stdint.h> |
| 8 #include <sstream> | 8 #include <sstream> |
| 9 #include <utility> | 9 #include <utility> |
| 10 | 10 |
| (...skipping 2603 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2614 ui_test_utils::NavigateToURL(browser(), url); | 2614 ui_test_utils::NavigateToURL(browser(), url); |
| 2615 | 2615 |
| 2616 std::unique_ptr<content::DownloadTestObserver> waiter( | 2616 std::unique_ptr<content::DownloadTestObserver> waiter( |
| 2617 new content::DownloadTestObserverTerminal( | 2617 new content::DownloadTestObserverTerminal( |
| 2618 DownloadManagerForBrowser(browser()), 1, | 2618 DownloadManagerForBrowser(browser()), 1, |
| 2619 content::DownloadTestObserver::ON_DANGEROUS_DOWNLOAD_FAIL)); | 2619 content::DownloadTestObserver::ON_DANGEROUS_DOWNLOAD_FAIL)); |
| 2620 | 2620 |
| 2621 // Click on the link with the alt key pressed. This will download the link | 2621 // Click on the link with the alt key pressed. This will download the link |
| 2622 // target. | 2622 // target. |
| 2623 WebContents* tab = browser()->tab_strip_model()->GetActiveWebContents(); | 2623 WebContents* tab = browser()->tab_strip_model()->GetActiveWebContents(); |
| 2624 blink::WebMouseEvent mouse_event; | 2624 blink::WebMouseEvent mouse_event(blink::WebInputEvent::MouseDown, |
| 2625 mouse_event.type = blink::WebInputEvent::MouseDown; | 2625 blink::WebInputEvent::AltKey, |
| 2626 blink::WebInputEvent::TimeStampForTesting); |
| 2626 mouse_event.button = blink::WebMouseEvent::Button::Left; | 2627 mouse_event.button = blink::WebMouseEvent::Button::Left; |
| 2627 mouse_event.x = 15; | 2628 mouse_event.x = 15; |
| 2628 mouse_event.y = 15; | 2629 mouse_event.y = 15; |
| 2629 mouse_event.clickCount = 1; | 2630 mouse_event.clickCount = 1; |
| 2630 mouse_event.modifiers = blink::WebInputEvent::AltKey; | |
| 2631 tab->GetRenderViewHost()->GetWidget()->ForwardMouseEvent(mouse_event); | 2631 tab->GetRenderViewHost()->GetWidget()->ForwardMouseEvent(mouse_event); |
| 2632 mouse_event.type = blink::WebInputEvent::MouseUp; | 2632 mouse_event.setType(blink::WebInputEvent::MouseUp); |
| 2633 tab->GetRenderViewHost()->GetWidget()->ForwardMouseEvent(mouse_event); | 2633 tab->GetRenderViewHost()->GetWidget()->ForwardMouseEvent(mouse_event); |
| 2634 | 2634 |
| 2635 waiter->WaitForFinished(); | 2635 waiter->WaitForFinished(); |
| 2636 EXPECT_EQ(1u, waiter->NumDownloadsSeenInState(DownloadItem::COMPLETE)); | 2636 EXPECT_EQ(1u, waiter->NumDownloadsSeenInState(DownloadItem::COMPLETE)); |
| 2637 CheckDownloadStates(1, DownloadItem::COMPLETE); | 2637 CheckDownloadStates(1, DownloadItem::COMPLETE); |
| 2638 | 2638 |
| 2639 // Validate that the correct file was downloaded. | 2639 // Validate that the correct file was downloaded. |
| 2640 GetDownloads(browser(), &download_items); | 2640 GetDownloads(browser(), &download_items); |
| 2641 ASSERT_EQ(1u, download_items.size()); | 2641 ASSERT_EQ(1u, download_items.size()); |
| 2642 ASSERT_EQ(embedded_test_server()->GetURL("/echoreferrer"), | 2642 ASSERT_EQ(embedded_test_server()->GetURL("/echoreferrer"), |
| (...skipping 28 matching lines...) Expand all Loading... |
| 2671 new content::DownloadTestObserverTerminal( | 2671 new content::DownloadTestObserverTerminal( |
| 2672 DownloadManagerForBrowser(browser()), 1, | 2672 DownloadManagerForBrowser(browser()), 1, |
| 2673 content::DownloadTestObserver::ON_DANGEROUS_DOWNLOAD_FAIL)); | 2673 content::DownloadTestObserver::ON_DANGEROUS_DOWNLOAD_FAIL)); |
| 2674 | 2674 |
| 2675 // Right-click on the link and choose Save Link As. This will download the | 2675 // Right-click on the link and choose Save Link As. This will download the |
| 2676 // link target. | 2676 // link target. |
| 2677 ContextMenuNotificationObserver context_menu_observer( | 2677 ContextMenuNotificationObserver context_menu_observer( |
| 2678 IDC_CONTENT_CONTEXT_SAVELINKAS); | 2678 IDC_CONTENT_CONTEXT_SAVELINKAS); |
| 2679 | 2679 |
| 2680 WebContents* tab = browser()->tab_strip_model()->GetActiveWebContents(); | 2680 WebContents* tab = browser()->tab_strip_model()->GetActiveWebContents(); |
| 2681 blink::WebMouseEvent mouse_event; | 2681 blink::WebMouseEvent mouse_event(blink::WebInputEvent::MouseDown, |
| 2682 mouse_event.type = blink::WebInputEvent::MouseDown; | 2682 blink::WebInputEvent::NoModifiers, |
| 2683 blink::WebInputEvent::TimeStampForTesting); |
| 2683 mouse_event.button = blink::WebMouseEvent::Button::Right; | 2684 mouse_event.button = blink::WebMouseEvent::Button::Right; |
| 2684 mouse_event.x = 15; | 2685 mouse_event.x = 15; |
| 2685 mouse_event.y = 15; | 2686 mouse_event.y = 15; |
| 2686 mouse_event.clickCount = 1; | 2687 mouse_event.clickCount = 1; |
| 2687 tab->GetRenderViewHost()->GetWidget()->ForwardMouseEvent(mouse_event); | 2688 tab->GetRenderViewHost()->GetWidget()->ForwardMouseEvent(mouse_event); |
| 2688 mouse_event.type = blink::WebInputEvent::MouseUp; | 2689 mouse_event.setType(blink::WebInputEvent::MouseUp); |
| 2689 tab->GetRenderViewHost()->GetWidget()->ForwardMouseEvent(mouse_event); | 2690 tab->GetRenderViewHost()->GetWidget()->ForwardMouseEvent(mouse_event); |
| 2690 | 2691 |
| 2691 waiter->WaitForFinished(); | 2692 waiter->WaitForFinished(); |
| 2692 EXPECT_EQ(1u, waiter->NumDownloadsSeenInState(DownloadItem::COMPLETE)); | 2693 EXPECT_EQ(1u, waiter->NumDownloadsSeenInState(DownloadItem::COMPLETE)); |
| 2693 CheckDownloadStates(1, DownloadItem::COMPLETE); | 2694 CheckDownloadStates(1, DownloadItem::COMPLETE); |
| 2694 | 2695 |
| 2695 // Validate that the correct file was downloaded. | 2696 // Validate that the correct file was downloaded. |
| 2696 GetDownloads(browser(), &download_items); | 2697 GetDownloads(browser(), &download_items); |
| 2697 EXPECT_EQ(1u, download_items.size()); | 2698 EXPECT_EQ(1u, download_items.size()); |
| 2698 EXPECT_EQ(embedded_test_server()->GetURL("/echoreferrer"), | 2699 EXPECT_EQ(embedded_test_server()->GetURL("/echoreferrer"), |
| (...skipping 1038 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3737 browser(), 1, | 3738 browser(), 1, |
| 3738 content::DownloadTestObserver::ON_DANGEROUS_DOWNLOAD_DENY)); | 3739 content::DownloadTestObserver::ON_DANGEROUS_DOWNLOAD_DENY)); |
| 3739 ui_test_utils::NavigateToURL(browser(), extension_url); | 3740 ui_test_utils::NavigateToURL(browser(), extension_url); |
| 3740 | 3741 |
| 3741 observer->WaitForFinished(); | 3742 observer->WaitForFinished(); |
| 3742 | 3743 |
| 3743 // Download shelf should close. | 3744 // Download shelf should close. |
| 3744 EXPECT_FALSE(browser()->window()->IsDownloadShelfVisible()); | 3745 EXPECT_FALSE(browser()->window()->IsDownloadShelfVisible()); |
| 3745 } | 3746 } |
| 3746 #endif // defined(OS_CHROMEOS) | 3747 #endif // defined(OS_CHROMEOS) |
| OLD | NEW |