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

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

Issue 9015022: Replace most of Browser::GetSelectedTabContents calls into Browser::GetSelectedWebContents. I've ... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 8 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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/bind.h" 5 #include "base/bind.h"
6 #include "base/bind_helpers.h" 6 #include "base/bind_helpers.h"
7 #include "base/file_path.h" 7 #include "base/file_path.h"
8 #include "base/file_util.h" 8 #include "base/file_util.h"
9 #include "base/memory/ref_counted.h" 9 #include "base/memory/ref_counted.h"
10 #include "base/path_service.h" 10 #include "base/path_service.h"
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
48 #include "content/browser/tab_contents/tab_contents.h" 48 #include "content/browser/tab_contents/tab_contents.h"
49 #include "content/public/browser/download_item.h" 49 #include "content/public/browser/download_item.h"
50 #include "content/public/browser/download_manager.h" 50 #include "content/public/browser/download_manager.h"
51 #include "content/public/common/page_transition_types.h" 51 #include "content/public/common/page_transition_types.h"
52 #include "net/base/net_util.h" 52 #include "net/base/net_util.h"
53 #include "testing/gtest/include/gtest/gtest.h" 53 #include "testing/gtest/include/gtest/gtest.h"
54 54
55 using content::BrowserThread; 55 using content::BrowserThread;
56 using content::DownloadItem; 56 using content::DownloadItem;
57 using content::DownloadManager; 57 using content::DownloadManager;
58 using content::WebContents;
58 59
59 namespace { 60 namespace {
60 61
61 // IDs and paths of CRX files used in tests. 62 // IDs and paths of CRX files used in tests.
62 const char kGoodCrxId[] = "ldnnhddmnhbkjipkidpdiheffobcpfmf"; 63 const char kGoodCrxId[] = "ldnnhddmnhbkjipkidpdiheffobcpfmf";
63 const FilePath kGoodCrxPath(FILE_PATH_LITERAL("extensions/good.crx")); 64 const FilePath kGoodCrxPath(FILE_PATH_LITERAL("extensions/good.crx"));
64 65
65 const char kLargeThemeCrxId[] = "pjpgmfcmabopnnfonnhmdjglfpjjfkbf"; 66 const char kLargeThemeCrxId[] = "pjpgmfcmabopnnfonnhmdjglfpjjfkbf";
66 const FilePath kLargeThemePath(FILE_PATH_LITERAL("extensions/theme2.crx")); 67 const FilePath kLargeThemePath(FILE_PATH_LITERAL("extensions/theme2.crx"));
67 68
(...skipping 520 matching lines...) Expand 10 before | Expand all | Expand 10 after
588 // is present in the UI (currently only on chromeos). 589 // is present in the UI (currently only on chromeos).
589 void CheckDownloadUI(Browser* browser, bool expected_non_cros, 590 void CheckDownloadUI(Browser* browser, bool expected_non_cros,
590 bool expected_cros, const FilePath& filename) { 591 bool expected_cros, const FilePath& filename) {
591 #if defined(OS_CHROMEOS) && !defined(USE_AURA) 592 #if defined(OS_CHROMEOS) && !defined(USE_AURA)
592 Browser* popup = ActiveDownloadsUI::GetPopup(); 593 Browser* popup = ActiveDownloadsUI::GetPopup();
593 EXPECT_EQ(expected_cros, popup != NULL); 594 EXPECT_EQ(expected_cros, popup != NULL);
594 if (!popup || filename.empty()) 595 if (!popup || filename.empty())
595 return; 596 return;
596 597
597 ActiveDownloadsUI* downloads_ui = static_cast<ActiveDownloadsUI*>( 598 ActiveDownloadsUI* downloads_ui = static_cast<ActiveDownloadsUI*>(
598 popup->GetSelectedTabContents()->GetWebUI()); 599 popup->GetSelectedWebContents()->GetWebUI());
599 600
600 ASSERT_TRUE(downloads_ui); 601 ASSERT_TRUE(downloads_ui);
601 const ActiveDownloadsUI::DownloadList& downloads = 602 const ActiveDownloadsUI::DownloadList& downloads =
602 downloads_ui->GetDownloads(); 603 downloads_ui->GetDownloads();
603 EXPECT_EQ(downloads.size(), 1U); 604 EXPECT_EQ(downloads.size(), 1U);
604 605
605 FilePath full_path(DestinationFile(browser, filename)); 606 FilePath full_path(DestinationFile(browser, filename));
606 bool exists = false; 607 bool exists = false;
607 for (size_t i = 0; i < downloads.size(); ++i) { 608 for (size_t i = 0; i < downloads.size(); ++i) {
608 if (downloads[i]->GetFullPath() == full_path) { 609 if (downloads[i]->GetFullPath() == full_path) {
(...skipping 707 matching lines...) Expand 10 before | Expand all | Expand 10 after
1316 ASSERT_TRUE(InitialSetup(false)); 1317 ASSERT_TRUE(InitialSetup(false));
1317 FilePath file(FILE_PATH_LITERAL("download-test1.lib")); 1318 FilePath file(FILE_PATH_LITERAL("download-test1.lib"));
1318 GURL download_url(URLRequestMockHTTPJob::GetMockUrl(file)); 1319 GURL download_url(URLRequestMockHTTPJob::GetMockUrl(file));
1319 GURL flags_url(chrome::kChromeUIFlagsURL); 1320 GURL flags_url(chrome::kChromeUIFlagsURL);
1320 GURL extensions_url(GURL(std::string(chrome::kChromeUISettingsURL) + 1321 GURL extensions_url(GURL(std::string(chrome::kChromeUISettingsURL) +
1321 chrome::kExtensionsSubPage)); 1322 chrome::kExtensionsSubPage));
1322 1323
1323 ui_test_utils::NavigateToURL(browser(), flags_url); 1324 ui_test_utils::NavigateToURL(browser(), flags_url);
1324 DownloadAndWait(browser(), download_url, EXPECT_NO_SELECT_DIALOG); 1325 DownloadAndWait(browser(), download_url, EXPECT_NO_SELECT_DIALOG);
1325 ui_test_utils::NavigateToURL(browser(), extensions_url); 1326 ui_test_utils::NavigateToURL(browser(), extensions_url);
1326 TabContents* contents = browser()->GetSelectedTabContents(); 1327 WebContents* contents = browser()->GetSelectedWebContents();
1327 ASSERT_TRUE(contents); 1328 ASSERT_TRUE(contents);
1328 bool webui_responded = false; 1329 bool webui_responded = false;
1329 EXPECT_TRUE(ui_test_utils::ExecuteJavaScriptAndExtractBool( 1330 EXPECT_TRUE(ui_test_utils::ExecuteJavaScriptAndExtractBool(
1330 contents->GetRenderViewHost(), 1331 contents->GetRenderViewHost(),
1331 L"", 1332 L"",
1332 L"window.domAutomationController.send(window.webui_responded_);", 1333 L"window.domAutomationController.send(window.webui_responded_);",
1333 &webui_responded)); 1334 &webui_responded));
1334 EXPECT_TRUE(webui_responded); 1335 EXPECT_TRUE(webui_responded);
1335 } 1336 }
1336 1337
1337 // Test for crbug.com/12745. This tests that if a download is initiated from 1338 // Test for crbug.com/12745. This tests that if a download is initiated from
1338 // a chrome:// page that has registered and onunload handler, the browser 1339 // a chrome:// page that has registered and onunload handler, the browser
1339 // will be able to close. 1340 // will be able to close.
1340 IN_PROC_BROWSER_TEST_F(DownloadTest, BrowserCloseAfterDownload) { 1341 IN_PROC_BROWSER_TEST_F(DownloadTest, BrowserCloseAfterDownload) {
1341 ASSERT_TRUE(InitialSetup(false)); 1342 ASSERT_TRUE(InitialSetup(false));
1342 GURL downloads_url(chrome::kChromeUIFlagsURL); 1343 GURL downloads_url(chrome::kChromeUIFlagsURL);
1343 FilePath file(FILE_PATH_LITERAL("download-test1.lib")); 1344 FilePath file(FILE_PATH_LITERAL("download-test1.lib"));
1344 GURL download_url(URLRequestMockHTTPJob::GetMockUrl(file)); 1345 GURL download_url(URLRequestMockHTTPJob::GetMockUrl(file));
1345 1346
1346 ui_test_utils::NavigateToURL(browser(), downloads_url); 1347 ui_test_utils::NavigateToURL(browser(), downloads_url);
1347 TabContents* contents = browser()->GetSelectedTabContents(); 1348 WebContents* contents = browser()->GetSelectedWebContents();
1348 ASSERT_TRUE(contents); 1349 ASSERT_TRUE(contents);
1349 bool result = false; 1350 bool result = false;
1350 EXPECT_TRUE(ui_test_utils::ExecuteJavaScriptAndExtractBool( 1351 EXPECT_TRUE(ui_test_utils::ExecuteJavaScriptAndExtractBool(
1351 contents->GetRenderViewHost(), 1352 contents->GetRenderViewHost(),
1352 L"", 1353 L"",
1353 L"window.onunload = function() { var do_nothing = 0; }; " 1354 L"window.onunload = function() { var do_nothing = 0; }; "
1354 L"window.domAutomationController.send(true);", 1355 L"window.domAutomationController.send(true);",
1355 &result)); 1356 &result));
1356 EXPECT_TRUE(result); 1357 EXPECT_TRUE(result);
1357 1358
(...skipping 373 matching lines...) Expand 10 before | Expand all | Expand 10 after
1731 1732
1732 // Check state. 1733 // Check state.
1733 EXPECT_EQ(1, browser()->tab_count()); 1734 EXPECT_EQ(1, browser()->tab_count());
1734 ASSERT_TRUE(CheckDownloadFullPaths(browser(), 1735 ASSERT_TRUE(CheckDownloadFullPaths(browser(),
1735 target_file_full_path, 1736 target_file_full_path,
1736 OriginFile(file))); 1737 OriginFile(file)));
1737 1738
1738 // Temporary downloads won't be visible. 1739 // Temporary downloads won't be visible.
1739 CheckDownloadUI(browser(), false, false, file); 1740 CheckDownloadUI(browser(), false, false, file);
1740 } 1741 }
OLDNEW
« no previous file with comments | « chrome/browser/debugger/devtools_window.cc ('k') | chrome/browser/extensions/app_process_apitest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698