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

Side by Side Diff: chrome/browser/download/download_browsertest.cc

Issue 10545064: TabContentsWrapper -> TabContents, part 11. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 6 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 | Annotate | Revision Log
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 <sstream> 5 #include <sstream>
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/bind_helpers.h" 8 #include "base/bind_helpers.h"
9 #include "base/file_path.h" 9 #include "base/file_path.h"
10 #include "base/file_util.h" 10 #include "base/file_util.h"
(...skipping 632 matching lines...) Expand 10 before | Expand all | Expand 10 after
643 std::vector<DownloadItem*> download_items; 643 std::vector<DownloadItem*> download_items;
644 GetDownloads(browser(), &download_items); 644 GetDownloads(browser(), &download_items);
645 size_t downloads_expected = download_items.size(); 645 size_t downloads_expected = download_items.size();
646 646
647 std::string server_path = "files/downloads/"; 647 std::string server_path = "files/downloads/";
648 server_path += download_info.url_name; 648 server_path += download_info.url_name;
649 GURL url = test_server()->GetURL(server_path); 649 GURL url = test_server()->GetURL(server_path);
650 ASSERT_TRUE(url.is_valid()) << s.str(); 650 ASSERT_TRUE(url.is_valid()) << s.str();
651 651
652 DownloadManager* download_manager = DownloadManagerForBrowser(browser()); 652 DownloadManager* download_manager = DownloadManagerForBrowser(browser());
653 WebContents* web_contents = browser()->GetSelectedWebContents(); 653 WebContents* web_contents = browser()->GetActiveWebContents();
654 ASSERT_TRUE(web_contents) << s.str(); 654 ASSERT_TRUE(web_contents) << s.str();
655 655
656 scoped_ptr<DownloadTestObserver> observer( 656 scoped_ptr<DownloadTestObserver> observer(
657 new DownloadTestObserverTerminal( 657 new DownloadTestObserverTerminal(
658 download_manager, 658 download_manager,
659 1, 659 1,
660 false, // Don't bail on select file. 660 false, // Don't bail on select file.
661 DownloadTestObserver::ON_DANGEROUS_DOWNLOAD_FAIL)); 661 DownloadTestObserver::ON_DANGEROUS_DOWNLOAD_FAIL));
662 662
663 if (download_info.download_method == DOWNLOAD_DIRECT) { 663 if (download_info.download_method == DOWNLOAD_DIRECT) {
(...skipping 288 matching lines...) Expand 10 before | Expand all | Expand 10 after
952 // navigate directly to the file we don't want to download because cross-site 952 // navigate directly to the file we don't want to download because cross-site
953 // navigations reset the TabDownloadState. 953 // navigations reset the TabDownloadState.
954 FilePath same_site_path(FILE_PATH_LITERAL("download_script.html")); 954 FilePath same_site_path(FILE_PATH_LITERAL("download_script.html"));
955 GURL same_site_url(URLRequestMockHTTPJob::GetMockUrl(same_site_path)); 955 GURL same_site_url(URLRequestMockHTTPJob::GetMockUrl(same_site_path));
956 ui_test_utils::NavigateToURL(browser(), same_site_url); 956 ui_test_utils::NavigateToURL(browser(), same_site_url);
957 957
958 // Make sure the initial navigation didn't trigger a download. 958 // Make sure the initial navigation didn't trigger a download.
959 EXPECT_TRUE(EnsureNoPendingDownloads()); 959 EXPECT_TRUE(EnsureNoPendingDownloads());
960 960
961 // Disable downloads for the tab. 961 // Disable downloads for the tab.
962 WebContents* web_contents = browser()->GetSelectedWebContents(); 962 WebContents* web_contents = browser()->GetActiveWebContents();
963 DownloadRequestLimiter::TabDownloadState* tab_download_state = 963 DownloadRequestLimiter::TabDownloadState* tab_download_state =
964 g_browser_process->download_request_limiter()->GetDownloadState( 964 g_browser_process->download_request_limiter()->GetDownloadState(
965 web_contents, web_contents, true); 965 web_contents, web_contents, true);
966 ASSERT_TRUE(tab_download_state); 966 ASSERT_TRUE(tab_download_state);
967 tab_download_state->set_download_status( 967 tab_download_state->set_download_status(
968 DownloadRequestLimiter::DOWNLOADS_NOT_ALLOWED); 968 DownloadRequestLimiter::DOWNLOADS_NOT_ALLOWED);
969 969
970 // Try to start the download via Javascript and wait for the corresponding 970 // Try to start the download via Javascript and wait for the corresponding
971 // load stop event. 971 // load stop event.
972 content::TestNavigationObserver observer( 972 content::TestNavigationObserver observer(
973 content::Source<content::NavigationController>( 973 content::Source<content::NavigationController>(
974 &web_contents->GetController()), 974 &web_contents->GetController()),
975 NULL, 975 NULL,
976 1); 976 1);
977 bool download_assempted; 977 bool download_assempted;
978 ASSERT_TRUE(ui_test_utils::ExecuteJavaScriptAndExtractBool( 978 ASSERT_TRUE(ui_test_utils::ExecuteJavaScriptAndExtractBool(
979 browser()->GetSelectedWebContents()->GetRenderViewHost(), 979 browser()->GetActiveWebContents()->GetRenderViewHost(),
980 L"", 980 L"",
981 L"window.domAutomationController.send(startDownload());", 981 L"window.domAutomationController.send(startDownload());",
982 &download_assempted)); 982 &download_assempted));
983 ASSERT_TRUE(download_assempted); 983 ASSERT_TRUE(download_assempted);
984 observer.WaitForObservation( 984 observer.WaitForObservation(
985 base::Bind(&ui_test_utils::RunMessageLoop), 985 base::Bind(&ui_test_utils::RunMessageLoop),
986 base::Bind(&MessageLoop::Quit, 986 base::Bind(&MessageLoop::Quit,
987 base::Unretained(MessageLoopForUI::current()))); 987 base::Unretained(MessageLoopForUI::current())));
988 988
989 // Check that we did not download the file. 989 // Check that we did not download the file.
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
1029 // Download a file and wait. 1029 // Download a file and wait.
1030 DownloadAndWait(browser(), url, EXPECT_NO_SELECT_DIALOG); 1030 DownloadAndWait(browser(), url, EXPECT_NO_SELECT_DIALOG);
1031 1031
1032 CheckDownload(browser(), download_file, file); 1032 CheckDownload(browser(), download_file, file);
1033 1033
1034 // Check state. 1034 // Check state.
1035 EXPECT_EQ(1, browser()->tab_count()); 1035 EXPECT_EQ(1, browser()->tab_count());
1036 EXPECT_TRUE(browser()->window()->IsDownloadShelfVisible()); 1036 EXPECT_TRUE(browser()->window()->IsDownloadShelfVisible());
1037 1037
1038 // Open a second tab and wait. 1038 // Open a second tab and wait.
1039 EXPECT_NE(static_cast<TabContentsWrapper*>(NULL), 1039 EXPECT_NE(static_cast<TabContents*>(NULL),
1040 browser()->AddSelectedTabWithURL( 1040 browser()->AddSelectedTabWithURL(
1041 GURL(), content::PAGE_TRANSITION_TYPED)); 1041 GURL(), content::PAGE_TRANSITION_TYPED));
1042 EXPECT_EQ(2, browser()->tab_count()); 1042 EXPECT_EQ(2, browser()->tab_count());
1043 EXPECT_TRUE(browser()->window()->IsDownloadShelfVisible()); 1043 EXPECT_TRUE(browser()->window()->IsDownloadShelfVisible());
1044 1044
1045 // Hide the download shelf. 1045 // Hide the download shelf.
1046 browser()->window()->GetDownloadShelf()->Close(); 1046 browser()->window()->GetDownloadShelf()->Close();
1047 EXPECT_FALSE(browser()->window()->IsDownloadShelfVisible()); 1047 EXPECT_FALSE(browser()->window()->IsDownloadShelfVisible());
1048 1048
1049 // Go to the first tab. 1049 // Go to the first tab.
(...skipping 496 matching lines...) Expand 10 before | Expand all | Expand 10 after
1546 // after download of a file while viewing another chrome://. 1546 // after download of a file while viewing another chrome://.
1547 IN_PROC_BROWSER_TEST_F(DownloadTest, ChromeURLAfterDownload) { 1547 IN_PROC_BROWSER_TEST_F(DownloadTest, ChromeURLAfterDownload) {
1548 FilePath file(FILE_PATH_LITERAL("download-test1.lib")); 1548 FilePath file(FILE_PATH_LITERAL("download-test1.lib"));
1549 GURL download_url(URLRequestMockHTTPJob::GetMockUrl(file)); 1549 GURL download_url(URLRequestMockHTTPJob::GetMockUrl(file));
1550 GURL flags_url(chrome::kChromeUIFlagsURL); 1550 GURL flags_url(chrome::kChromeUIFlagsURL);
1551 GURL extensions_url(chrome::kChromeUIExtensionsFrameURL); 1551 GURL extensions_url(chrome::kChromeUIExtensionsFrameURL);
1552 1552
1553 ui_test_utils::NavigateToURL(browser(), flags_url); 1553 ui_test_utils::NavigateToURL(browser(), flags_url);
1554 DownloadAndWait(browser(), download_url, EXPECT_NO_SELECT_DIALOG); 1554 DownloadAndWait(browser(), download_url, EXPECT_NO_SELECT_DIALOG);
1555 ui_test_utils::NavigateToURL(browser(), extensions_url); 1555 ui_test_utils::NavigateToURL(browser(), extensions_url);
1556 WebContents* contents = browser()->GetSelectedWebContents(); 1556 WebContents* contents = browser()->GetActiveWebContents();
1557 ASSERT_TRUE(contents); 1557 ASSERT_TRUE(contents);
1558 bool webui_responded = false; 1558 bool webui_responded = false;
1559 EXPECT_TRUE(ui_test_utils::ExecuteJavaScriptAndExtractBool( 1559 EXPECT_TRUE(ui_test_utils::ExecuteJavaScriptAndExtractBool(
1560 contents->GetRenderViewHost(), 1560 contents->GetRenderViewHost(),
1561 L"", 1561 L"",
1562 L"window.domAutomationController.send(window.webui_responded_);", 1562 L"window.domAutomationController.send(window.webui_responded_);",
1563 &webui_responded)); 1563 &webui_responded));
1564 EXPECT_TRUE(webui_responded); 1564 EXPECT_TRUE(webui_responded);
1565 } 1565 }
1566 1566
1567 // Test for crbug.com/12745. This tests that if a download is initiated from 1567 // Test for crbug.com/12745. This tests that if a download is initiated from
1568 // a chrome:// page that has registered and onunload handler, the browser 1568 // a chrome:// page that has registered and onunload handler, the browser
1569 // will be able to close. 1569 // will be able to close.
1570 IN_PROC_BROWSER_TEST_F(DownloadTest, BrowserCloseAfterDownload) { 1570 IN_PROC_BROWSER_TEST_F(DownloadTest, BrowserCloseAfterDownload) {
1571 GURL downloads_url(chrome::kChromeUIFlagsURL); 1571 GURL downloads_url(chrome::kChromeUIFlagsURL);
1572 FilePath file(FILE_PATH_LITERAL("download-test1.lib")); 1572 FilePath file(FILE_PATH_LITERAL("download-test1.lib"));
1573 GURL download_url(URLRequestMockHTTPJob::GetMockUrl(file)); 1573 GURL download_url(URLRequestMockHTTPJob::GetMockUrl(file));
1574 1574
1575 ui_test_utils::NavigateToURL(browser(), downloads_url); 1575 ui_test_utils::NavigateToURL(browser(), downloads_url);
1576 WebContents* contents = browser()->GetSelectedWebContents(); 1576 WebContents* contents = browser()->GetActiveWebContents();
1577 ASSERT_TRUE(contents); 1577 ASSERT_TRUE(contents);
1578 bool result = false; 1578 bool result = false;
1579 EXPECT_TRUE(ui_test_utils::ExecuteJavaScriptAndExtractBool( 1579 EXPECT_TRUE(ui_test_utils::ExecuteJavaScriptAndExtractBool(
1580 contents->GetRenderViewHost(), 1580 contents->GetRenderViewHost(),
1581 L"", 1581 L"",
1582 L"window.onunload = function() { var do_nothing = 0; }; " 1582 L"window.onunload = function() { var do_nothing = 0; }; "
1583 L"window.domAutomationController.send(true);", 1583 L"window.domAutomationController.send(true);",
1584 &result)); 1584 &result));
1585 EXPECT_TRUE(result); 1585 EXPECT_TRUE(result);
1586 1586
(...skipping 344 matching lines...) Expand 10 before | Expand all | Expand 10 after
1931 } 1931 }
1932 1932
1933 // Tests for download initiation functions. 1933 // Tests for download initiation functions.
1934 IN_PROC_BROWSER_TEST_F(DownloadTest, DownloadUrl) { 1934 IN_PROC_BROWSER_TEST_F(DownloadTest, DownloadUrl) {
1935 FilePath file(FILE_PATH_LITERAL("download-test1.lib")); 1935 FilePath file(FILE_PATH_LITERAL("download-test1.lib"));
1936 GURL url(URLRequestMockHTTPJob::GetMockUrl(file)); 1936 GURL url(URLRequestMockHTTPJob::GetMockUrl(file));
1937 1937
1938 // DownloadUrl always prompts; return acceptance of whatever it prompts. 1938 // DownloadUrl always prompts; return acceptance of whatever it prompts.
1939 NullSelectFile(browser()); 1939 NullSelectFile(browser());
1940 1940
1941 WebContents* web_contents = browser()->GetSelectedWebContents(); 1941 WebContents* web_contents = browser()->GetActiveWebContents();
1942 ASSERT_TRUE(web_contents); 1942 ASSERT_TRUE(web_contents);
1943 1943
1944 DownloadTestObserver* observer( 1944 DownloadTestObserver* observer(
1945 new DownloadTestObserverTerminal( 1945 new DownloadTestObserverTerminal(
1946 DownloadManagerForBrowser(browser()), 1, 1946 DownloadManagerForBrowser(browser()), 1,
1947 false, // Ignore select file. 1947 false, // Ignore select file.
1948 DownloadTestObserver::ON_DANGEROUS_DOWNLOAD_FAIL)); 1948 DownloadTestObserver::ON_DANGEROUS_DOWNLOAD_FAIL));
1949 content::DownloadSaveInfo save_info; 1949 content::DownloadSaveInfo save_info;
1950 save_info.prompt_for_save_location = true; 1950 save_info.prompt_for_save_location = true;
1951 scoped_ptr<DownloadUrlParameters> params( 1951 scoped_ptr<DownloadUrlParameters> params(
1952 DownloadUrlParameters::FromWebContents(web_contents, url, save_info)); 1952 DownloadUrlParameters::FromWebContents(web_contents, url, save_info));
1953 DownloadManagerForBrowser(browser())->DownloadUrl(params.Pass()); 1953 DownloadManagerForBrowser(browser())->DownloadUrl(params.Pass());
1954 observer->WaitForFinished(); 1954 observer->WaitForFinished();
1955 EXPECT_EQ(1u, observer->NumDownloadsSeenInState(DownloadItem::COMPLETE)); 1955 EXPECT_EQ(1u, observer->NumDownloadsSeenInState(DownloadItem::COMPLETE));
1956 CheckDownloadStates(1, DownloadItem::COMPLETE); 1956 CheckDownloadStates(1, DownloadItem::COMPLETE);
1957 EXPECT_TRUE(observer->select_file_dialog_seen()); 1957 EXPECT_TRUE(observer->select_file_dialog_seen());
1958 1958
1959 // Check state. 1959 // Check state.
1960 EXPECT_EQ(1, browser()->tab_count()); 1960 EXPECT_EQ(1, browser()->tab_count());
1961 ASSERT_TRUE(CheckDownload(browser(), file, file)); 1961 ASSERT_TRUE(CheckDownload(browser(), file, file));
1962 EXPECT_TRUE(browser()->window()->IsDownloadShelfVisible()); 1962 EXPECT_TRUE(browser()->window()->IsDownloadShelfVisible());
1963 } 1963 }
1964 1964
1965 IN_PROC_BROWSER_TEST_F(DownloadTest, DownloadUrlToPath) { 1965 IN_PROC_BROWSER_TEST_F(DownloadTest, DownloadUrlToPath) {
1966 FilePath file(FILE_PATH_LITERAL("download-test1.lib")); 1966 FilePath file(FILE_PATH_LITERAL("download-test1.lib"));
1967 GURL url(URLRequestMockHTTPJob::GetMockUrl(file)); 1967 GURL url(URLRequestMockHTTPJob::GetMockUrl(file));
1968 1968
1969 WebContents* web_contents = browser()->GetSelectedWebContents(); 1969 WebContents* web_contents = browser()->GetActiveWebContents();
1970 ASSERT_TRUE(web_contents); 1970 ASSERT_TRUE(web_contents);
1971 1971
1972 ScopedTempDir other_directory; 1972 ScopedTempDir other_directory;
1973 ASSERT_TRUE(other_directory.CreateUniqueTempDir()); 1973 ASSERT_TRUE(other_directory.CreateUniqueTempDir());
1974 FilePath target_file_full_path 1974 FilePath target_file_full_path
1975 = other_directory.path().Append(file.BaseName()); 1975 = other_directory.path().Append(file.BaseName());
1976 content::DownloadSaveInfo save_info; 1976 content::DownloadSaveInfo save_info;
1977 save_info.file_path = target_file_full_path; 1977 save_info.file_path = target_file_full_path;
1978 1978
1979 DownloadTestObserver* observer(CreateWaiter(browser(), 1)); 1979 DownloadTestObserver* observer(CreateWaiter(browser(), 1));
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
2029 2029
2030 // Try to download it via a context menu. 2030 // Try to download it via a context menu.
2031 scoped_ptr<DownloadTestObserver> waiter_context_menu( 2031 scoped_ptr<DownloadTestObserver> waiter_context_menu(
2032 new DownloadTestObserverTerminal( 2032 new DownloadTestObserverTerminal(
2033 DownloadManagerForBrowser(browser()), 1, 2033 DownloadManagerForBrowser(browser()), 1,
2034 false, DownloadTestObserver::ON_DANGEROUS_DOWNLOAD_FAIL)); 2034 false, DownloadTestObserver::ON_DANGEROUS_DOWNLOAD_FAIL));
2035 content::ContextMenuParams context_menu_params; 2035 content::ContextMenuParams context_menu_params;
2036 context_menu_params.media_type = WebKit::WebContextMenuData::MediaTypeImage; 2036 context_menu_params.media_type = WebKit::WebContextMenuData::MediaTypeImage;
2037 context_menu_params.src_url = url; 2037 context_menu_params.src_url = url;
2038 context_menu_params.page_url = url; 2038 context_menu_params.page_url = url;
2039 TestRenderViewContextMenu menu(browser()->GetSelectedWebContents(), 2039 TestRenderViewContextMenu menu(browser()->GetActiveWebContents(),
2040 context_menu_params); 2040 context_menu_params);
2041 menu.Init(); 2041 menu.Init();
2042 menu.ExecuteCommand(IDC_CONTENT_CONTEXT_SAVEIMAGEAS); 2042 menu.ExecuteCommand(IDC_CONTENT_CONTEXT_SAVEIMAGEAS);
2043 waiter_context_menu->WaitForFinished(); 2043 waiter_context_menu->WaitForFinished();
2044 EXPECT_EQ( 2044 EXPECT_EQ(
2045 1u, waiter_context_menu->NumDownloadsSeenInState(DownloadItem::COMPLETE)); 2045 1u, waiter_context_menu->NumDownloadsSeenInState(DownloadItem::COMPLETE));
2046 CheckDownloadStates(2, DownloadItem::COMPLETE); 2046 CheckDownloadStates(2, DownloadItem::COMPLETE);
2047 2047
2048 // Validate that the correct file was downloaded via the context menu. 2048 // Validate that the correct file was downloaded via the context menu.
2049 download_items.clear(); 2049 download_items.clear();
(...skipping 16 matching lines...) Expand all
2066 GURL form_url = test_server()->GetURL( 2066 GURL form_url = test_server()->GetURL(
2067 "files/downloads/form_page_to_post.html"); 2067 "files/downloads/form_page_to_post.html");
2068 ASSERT_TRUE(form_url.is_valid()); 2068 ASSERT_TRUE(form_url.is_valid());
2069 ui_test_utils::NavigateToURL(browser(), form_url); 2069 ui_test_utils::NavigateToURL(browser(), form_url);
2070 2070
2071 // Submit the form. This will send a POST reqeuest, and the response is a 2071 // Submit the form. This will send a POST reqeuest, and the response is a
2072 // JPEG image. The resource also has Cache-Control: no-cache set, 2072 // JPEG image. The resource also has Cache-Control: no-cache set,
2073 // which normally requires revalidation each time. 2073 // which normally requires revalidation each time.
2074 GURL jpeg_url = test_server()->GetURL("files/post/downloads/image.jpg"); 2074 GURL jpeg_url = test_server()->GetURL("files/post/downloads/image.jpg");
2075 ASSERT_TRUE(jpeg_url.is_valid()); 2075 ASSERT_TRUE(jpeg_url.is_valid());
2076 WebContents* web_contents = browser()->GetSelectedWebContents(); 2076 WebContents* web_contents = browser()->GetActiveWebContents();
2077 ASSERT_TRUE(web_contents != NULL); 2077 ASSERT_TRUE(web_contents != NULL);
2078 ui_test_utils::WindowedNotificationObserver observer( 2078 ui_test_utils::WindowedNotificationObserver observer(
2079 content::NOTIFICATION_NAV_ENTRY_COMMITTED, 2079 content::NOTIFICATION_NAV_ENTRY_COMMITTED,
2080 content::Source<content::NavigationController>( 2080 content::Source<content::NavigationController>(
2081 &web_contents->GetController())); 2081 &web_contents->GetController()));
2082 content::RenderViewHost* render_view_host = web_contents->GetRenderViewHost(); 2082 content::RenderViewHost* render_view_host = web_contents->GetRenderViewHost();
2083 ASSERT_TRUE(render_view_host != NULL); 2083 ASSERT_TRUE(render_view_host != NULL);
2084 render_view_host->ExecuteJavascriptInWebFrame( 2084 render_view_host->ExecuteJavascriptInWebFrame(
2085 string16(), ASCIIToUTF16("SubmitForm()")); 2085 string16(), ASCIIToUTF16("SubmitForm()"));
2086 observer.Wait(); 2086 observer.Wait();
(...skipping 339 matching lines...) Expand 10 before | Expand all | Expand 10 after
2426 ASSERT_TRUE(url.is_valid()); 2426 ASSERT_TRUE(url.is_valid());
2427 ui_test_utils::NavigateToURL(browser(), url); 2427 ui_test_utils::NavigateToURL(browser(), url);
2428 2428
2429 scoped_ptr<DownloadTestObserver> waiter( 2429 scoped_ptr<DownloadTestObserver> waiter(
2430 new DownloadTestObserverTerminal( 2430 new DownloadTestObserverTerminal(
2431 DownloadManagerForBrowser(browser()), 1, 2431 DownloadManagerForBrowser(browser()), 1,
2432 false, DownloadTestObserver::ON_DANGEROUS_DOWNLOAD_FAIL)); 2432 false, DownloadTestObserver::ON_DANGEROUS_DOWNLOAD_FAIL));
2433 2433
2434 // Click on the link with the alt key pressed. This will download the link 2434 // Click on the link with the alt key pressed. This will download the link
2435 // target. 2435 // target.
2436 WebContents* tab = browser()->GetSelectedWebContents(); 2436 WebContents* tab = browser()->GetActiveWebContents();
2437 WebKit::WebMouseEvent mouse_event; 2437 WebKit::WebMouseEvent mouse_event;
2438 mouse_event.type = WebKit::WebInputEvent::MouseDown; 2438 mouse_event.type = WebKit::WebInputEvent::MouseDown;
2439 mouse_event.button = WebKit::WebMouseEvent::ButtonLeft; 2439 mouse_event.button = WebKit::WebMouseEvent::ButtonLeft;
2440 mouse_event.x = 15; 2440 mouse_event.x = 15;
2441 mouse_event.y = 15; 2441 mouse_event.y = 15;
2442 mouse_event.clickCount = 1; 2442 mouse_event.clickCount = 1;
2443 mouse_event.modifiers = WebKit::WebInputEvent::AltKey; 2443 mouse_event.modifiers = WebKit::WebInputEvent::AltKey;
2444 tab->GetRenderViewHost()->ForwardMouseEvent(mouse_event); 2444 tab->GetRenderViewHost()->ForwardMouseEvent(mouse_event);
2445 mouse_event.type = WebKit::WebInputEvent::MouseUp; 2445 mouse_event.type = WebKit::WebInputEvent::MouseUp;
2446 tab->GetRenderViewHost()->ForwardMouseEvent(mouse_event); 2446 tab->GetRenderViewHost()->ForwardMouseEvent(mouse_event);
2447 2447
2448 waiter->WaitForFinished(); 2448 waiter->WaitForFinished();
2449 EXPECT_EQ(1u, waiter->NumDownloadsSeenInState(DownloadItem::COMPLETE)); 2449 EXPECT_EQ(1u, waiter->NumDownloadsSeenInState(DownloadItem::COMPLETE));
2450 CheckDownloadStates(1, DownloadItem::COMPLETE); 2450 CheckDownloadStates(1, DownloadItem::COMPLETE);
2451 2451
2452 // Validate that the correct file was downloaded. 2452 // Validate that the correct file was downloaded.
2453 GetDownloads(browser(), &download_items); 2453 GetDownloads(browser(), &download_items);
2454 ASSERT_EQ(1u, download_items.size()); 2454 ASSERT_EQ(1u, download_items.size());
2455 ASSERT_EQ(test_server()->GetURL("echoheader?Referer"), 2455 ASSERT_EQ(test_server()->GetURL("echoheader?Referer"),
2456 download_items[0]->GetOriginalUrl()); 2456 download_items[0]->GetOriginalUrl());
2457 2457
2458 // Check that the file contains the expected referrer. 2458 // Check that the file contains the expected referrer.
2459 FilePath file(download_items[0]->GetFullPath()); 2459 FilePath file(download_items[0]->GetFullPath());
2460 std::string expected_contents = test_server()->GetURL("").spec(); 2460 std::string expected_contents = test_server()->GetURL("").spec();
2461 ASSERT_TRUE(VerifyFile(file, expected_contents, expected_contents.length())); 2461 ASSERT_TRUE(VerifyFile(file, expected_contents, expected_contents.length()));
2462 } 2462 }
OLDNEW
« no previous file with comments | « chrome/browser/download/chrome_download_manager_delegate.cc ('k') | chrome/browser/download/download_danger_prompt.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698