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

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

Issue 12212120: Replace most BrowserList::empty() and BrowserList::size() calls by multi-desktop aware calls. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: merge up to r182110 Created 7 years, 10 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 23 matching lines...) Expand all
34 #include "chrome/browser/extensions/extension_service.h" 34 #include "chrome/browser/extensions/extension_service.h"
35 #include "chrome/browser/extensions/extension_system.h" 35 #include "chrome/browser/extensions/extension_system.h"
36 #include "chrome/browser/history/download_row.h" 36 #include "chrome/browser/history/download_row.h"
37 #include "chrome/browser/history/history_service.h" 37 #include "chrome/browser/history/history_service.h"
38 #include "chrome/browser/history/history_service_factory.h" 38 #include "chrome/browser/history/history_service_factory.h"
39 #include "chrome/browser/net/url_request_mock_util.h" 39 #include "chrome/browser/net/url_request_mock_util.h"
40 #include "chrome/browser/profiles/profile.h" 40 #include "chrome/browser/profiles/profile.h"
41 #include "chrome/browser/tab_contents/render_view_context_menu.h" 41 #include "chrome/browser/tab_contents/render_view_context_menu.h"
42 #include "chrome/browser/ui/browser.h" 42 #include "chrome/browser/ui/browser.h"
43 #include "chrome/browser/ui/browser_commands.h" 43 #include "chrome/browser/ui/browser_commands.h"
44 #include "chrome/browser/ui/browser_list.h" 44 #include "chrome/browser/ui/browser_finder.h"
45 #include "chrome/browser/ui/browser_tabstrip.h" 45 #include "chrome/browser/ui/browser_tabstrip.h"
46 #include "chrome/browser/ui/browser_window.h" 46 #include "chrome/browser/ui/browser_window.h"
47 #include "chrome/browser/ui/chrome_pages.h" 47 #include "chrome/browser/ui/chrome_pages.h"
48 #include "chrome/browser/ui/host_desktop.h" 48 #include "chrome/browser/ui/host_desktop.h"
49 #include "chrome/browser/ui/tabs/tab_strip_model.h" 49 #include "chrome/browser/ui/tabs/tab_strip_model.h"
50 #include "chrome/common/chrome_notification_types.h" 50 #include "chrome/common/chrome_notification_types.h"
51 #include "chrome/common/chrome_paths.h" 51 #include "chrome/common/chrome_paths.h"
52 #include "chrome/common/extensions/feature_switch.h" 52 #include "chrome/common/extensions/feature_switch.h"
53 #include "chrome/common/pref_names.h" 53 #include "chrome/common/pref_names.h"
54 #include "chrome/common/url_constants.h" 54 #include "chrome/common/url_constants.h"
(...skipping 264 matching lines...) Expand 10 before | Expand all | Expand 10 after
319 319
320 // Returning false indicates a failure of the setup, and should be asserted 320 // Returning false indicates a failure of the setup, and should be asserted
321 // in the caller. 321 // in the caller.
322 virtual bool InitialSetup() { 322 virtual bool InitialSetup() {
323 bool have_test_dir = PathService::Get(chrome::DIR_TEST_DATA, &test_dir_); 323 bool have_test_dir = PathService::Get(chrome::DIR_TEST_DATA, &test_dir_);
324 EXPECT_TRUE(have_test_dir); 324 EXPECT_TRUE(have_test_dir);
325 if (!have_test_dir) 325 if (!have_test_dir)
326 return false; 326 return false;
327 327
328 // Sanity check default values for window / tab count and shelf visibility. 328 // Sanity check default values for window / tab count and shelf visibility.
329 int window_count = BrowserList::size(); 329 int window_count = chrome::GetTotalBrowserCount();
330 EXPECT_EQ(1, window_count); 330 EXPECT_EQ(1, window_count);
331 EXPECT_EQ(1, browser()->tab_strip_model()->count()); 331 EXPECT_EQ(1, browser()->tab_strip_model()->count());
332 EXPECT_FALSE(browser()->window()->IsDownloadShelfVisible()); 332 EXPECT_FALSE(browser()->window()->IsDownloadShelfVisible());
333 333
334 // Set up the temporary download folder. 334 // Set up the temporary download folder.
335 bool created_downloads_dir = CreateAndSetDownloadsDirectory(browser()); 335 bool created_downloads_dir = CreateAndSetDownloadsDirectory(browser());
336 EXPECT_TRUE(created_downloads_dir); 336 EXPECT_TRUE(created_downloads_dir);
337 if (!created_downloads_dir) 337 if (!created_downloads_dir)
338 return false; 338 return false;
339 browser()->profile()->GetPrefs()->SetBoolean( 339 browser()->profile()->GetPrefs()->SetBoolean(
(...skipping 260 matching lines...) Expand 10 before | Expand all | Expand 10 after
600 return true; 600 return true;
601 } 601 }
602 602
603 void GetDownloads(Browser* browser, std::vector<DownloadItem*>* downloads) { 603 void GetDownloads(Browser* browser, std::vector<DownloadItem*>* downloads) {
604 DCHECK(downloads); 604 DCHECK(downloads);
605 DownloadManager* manager = DownloadManagerForBrowser(browser); 605 DownloadManager* manager = DownloadManagerForBrowser(browser);
606 manager->GetAllDownloads(downloads); 606 manager->GetAllDownloads(downloads);
607 } 607 }
608 608
609 static void ExpectWindowCountAfterDownload(size_t expected) { 609 static void ExpectWindowCountAfterDownload(size_t expected) {
610 EXPECT_EQ(expected, BrowserList::size()); 610 EXPECT_EQ(expected, chrome::GetTotalBrowserCount());
611 } 611 }
612 612
613 void EnableFileChooser(bool enable) { 613 void EnableFileChooser(bool enable) {
614 file_activity_observer_->EnableFileChooser(enable); 614 file_activity_observer_->EnableFileChooser(enable);
615 } 615 }
616 616
617 bool DidShowFileChooser() { 617 bool DidShowFileChooser() {
618 return file_activity_observer_->TestAndResetDidShowFileChooser(); 618 return file_activity_observer_->TestAndResetDidShowFileChooser();
619 } 619 }
620 620
(...skipping 542 matching lines...) Expand 10 before | Expand all | Expand 10 after
1163 } 1163 }
1164 1164
1165 // Test that when downloading an item in Incognito mode, we don't crash when 1165 // Test that when downloading an item in Incognito mode, we don't crash when
1166 // closing the last Incognito window (http://crbug.com/13983). 1166 // closing the last Incognito window (http://crbug.com/13983).
1167 // Also check that the download shelf is not visible after closing the 1167 // Also check that the download shelf is not visible after closing the
1168 // Incognito window. 1168 // Incognito window.
1169 IN_PROC_BROWSER_TEST_F(DownloadTest, IncognitoDownload) { 1169 IN_PROC_BROWSER_TEST_F(DownloadTest, IncognitoDownload) {
1170 // Open an Incognito window. 1170 // Open an Incognito window.
1171 Browser* incognito = CreateIncognitoBrowser(); // Waits. 1171 Browser* incognito = CreateIncognitoBrowser(); // Waits.
1172 ASSERT_TRUE(incognito); 1172 ASSERT_TRUE(incognito);
1173 int window_count = BrowserList::size(); 1173 int window_count = chrome::GetTotalBrowserCount();
1174 EXPECT_EQ(2, window_count); 1174 EXPECT_EQ(2, window_count);
1175 1175
1176 // Download a file in the Incognito window and wait. 1176 // Download a file in the Incognito window and wait.
1177 CreateAndSetDownloadsDirectory(incognito); 1177 CreateAndSetDownloadsDirectory(incognito);
1178 base::FilePath file(FILE_PATH_LITERAL("download-test1.lib")); 1178 base::FilePath file(FILE_PATH_LITERAL("download-test1.lib"));
1179 GURL url(URLRequestMockHTTPJob::GetMockUrl(file)); 1179 GURL url(URLRequestMockHTTPJob::GetMockUrl(file));
1180 // Since |incognito| is a separate browser, we have to set it up explicitly. 1180 // Since |incognito| is a separate browser, we have to set it up explicitly.
1181 incognito->profile()->GetPrefs()->SetBoolean(prefs::kPromptForDownload, 1181 incognito->profile()->GetPrefs()->SetBoolean(prefs::kPromptForDownload,
1182 false); 1182 false);
1183 DownloadAndWait(incognito, url); 1183 DownloadAndWait(incognito, url);
(...skipping 1228 matching lines...) Expand 10 before | Expand all | Expand 10 after
2412 browser()->tab_strip_model()->GetActiveWebContents(); 2412 browser()->tab_strip_model()->GetActiveWebContents();
2413 scoped_ptr<DownloadUrlParameters> params( 2413 scoped_ptr<DownloadUrlParameters> params(
2414 DownloadUrlParameters::FromWebContents(web_contents, url)); 2414 DownloadUrlParameters::FromWebContents(web_contents, url));
2415 params->set_callback(base::Bind(&SetHiddenDownloadCallback)); 2415 params->set_callback(base::Bind(&SetHiddenDownloadCallback));
2416 download_manager->DownloadUrl(params.Pass()); 2416 download_manager->DownloadUrl(params.Pass());
2417 observer->WaitForFinished(); 2417 observer->WaitForFinished();
2418 2418
2419 // Verify that download shelf is not shown. 2419 // Verify that download shelf is not shown.
2420 EXPECT_FALSE(browser()->window()->IsDownloadShelfVisible()); 2420 EXPECT_FALSE(browser()->window()->IsDownloadShelfVisible());
2421 } 2421 }
OLDNEW
« no previous file with comments | « chrome/browser/devtools/browser_list_tabcontents_provider.cc ('k') | chrome/browser/fast_shutdown_browsertest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698