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

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: 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_system.h" 34 #include "chrome/browser/extensions/extension_system.h"
35 #include "chrome/browser/history/download_row.h" 35 #include "chrome/browser/history/download_row.h"
36 #include "chrome/browser/history/history_service.h" 36 #include "chrome/browser/history/history_service.h"
37 #include "chrome/browser/history/history_service_factory.h" 37 #include "chrome/browser/history/history_service_factory.h"
38 #include "chrome/browser/net/url_request_mock_util.h" 38 #include "chrome/browser/net/url_request_mock_util.h"
39 #include "chrome/browser/prefs/pref_service.h" 39 #include "chrome/browser/prefs/pref_service.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 253 matching lines...) Expand 10 before | Expand all | Expand 10 after
308 308
309 // Returning false indicates a failure of the setup, and should be asserted 309 // Returning false indicates a failure of the setup, and should be asserted
310 // in the caller. 310 // in the caller.
311 virtual bool InitialSetup() { 311 virtual bool InitialSetup() {
312 bool have_test_dir = PathService::Get(chrome::DIR_TEST_DATA, &test_dir_); 312 bool have_test_dir = PathService::Get(chrome::DIR_TEST_DATA, &test_dir_);
313 EXPECT_TRUE(have_test_dir); 313 EXPECT_TRUE(have_test_dir);
314 if (!have_test_dir) 314 if (!have_test_dir)
315 return false; 315 return false;
316 316
317 // Sanity check default values for window / tab count and shelf visibility. 317 // Sanity check default values for window / tab count and shelf visibility.
318 int window_count = BrowserList::size(); 318 int window_count = chrome::GetTotalBrowserCount();
319 EXPECT_EQ(1, window_count); 319 EXPECT_EQ(1, window_count);
320 EXPECT_EQ(1, browser()->tab_strip_model()->count()); 320 EXPECT_EQ(1, browser()->tab_strip_model()->count());
321 EXPECT_FALSE(browser()->window()->IsDownloadShelfVisible()); 321 EXPECT_FALSE(browser()->window()->IsDownloadShelfVisible());
322 322
323 // Set up the temporary download folder. 323 // Set up the temporary download folder.
324 bool created_downloads_dir = CreateAndSetDownloadsDirectory(browser()); 324 bool created_downloads_dir = CreateAndSetDownloadsDirectory(browser());
325 EXPECT_TRUE(created_downloads_dir); 325 EXPECT_TRUE(created_downloads_dir);
326 if (!created_downloads_dir) 326 if (!created_downloads_dir)
327 return false; 327 return false;
328 browser()->profile()->GetPrefs()->SetBoolean( 328 browser()->profile()->GetPrefs()->SetBoolean(
(...skipping 258 matching lines...) Expand 10 before | Expand all | Expand 10 after
587 return true; 587 return true;
588 } 588 }
589 589
590 void GetDownloads(Browser* browser, std::vector<DownloadItem*>* downloads) { 590 void GetDownloads(Browser* browser, std::vector<DownloadItem*>* downloads) {
591 DCHECK(downloads); 591 DCHECK(downloads);
592 DownloadManager* manager = DownloadManagerForBrowser(browser); 592 DownloadManager* manager = DownloadManagerForBrowser(browser);
593 manager->GetAllDownloads(downloads); 593 manager->GetAllDownloads(downloads);
594 } 594 }
595 595
596 static void ExpectWindowCountAfterDownload(size_t expected) { 596 static void ExpectWindowCountAfterDownload(size_t expected) {
597 EXPECT_EQ(expected, BrowserList::size()); 597 EXPECT_EQ(expected, chrome::GetTotalBrowserCount());
598 } 598 }
599 599
600 void EnableFileChooser(bool enable) { 600 void EnableFileChooser(bool enable) {
601 file_activity_observer_->EnableFileChooser(enable); 601 file_activity_observer_->EnableFileChooser(enable);
602 } 602 }
603 603
604 bool DidShowFileChooser() { 604 bool DidShowFileChooser() {
605 return file_activity_observer_->TestAndResetDidShowFileChooser(); 605 return file_activity_observer_->TestAndResetDidShowFileChooser();
606 } 606 }
607 607
(...skipping 540 matching lines...) Expand 10 before | Expand all | Expand 10 after
1148 } 1148 }
1149 1149
1150 // Test that when downloading an item in Incognito mode, we don't crash when 1150 // Test that when downloading an item in Incognito mode, we don't crash when
1151 // closing the last Incognito window (http://crbug.com/13983). 1151 // closing the last Incognito window (http://crbug.com/13983).
1152 // Also check that the download shelf is not visible after closing the 1152 // Also check that the download shelf is not visible after closing the
1153 // Incognito window. 1153 // Incognito window.
1154 IN_PROC_BROWSER_TEST_F(DownloadTest, IncognitoDownload) { 1154 IN_PROC_BROWSER_TEST_F(DownloadTest, IncognitoDownload) {
1155 // Open an Incognito window. 1155 // Open an Incognito window.
1156 Browser* incognito = CreateIncognitoBrowser(); // Waits. 1156 Browser* incognito = CreateIncognitoBrowser(); // Waits.
1157 ASSERT_TRUE(incognito); 1157 ASSERT_TRUE(incognito);
1158 int window_count = BrowserList::size(); 1158 int window_count = chrome::GetTotalBrowserCount();
1159 EXPECT_EQ(2, window_count); 1159 EXPECT_EQ(2, window_count);
1160 1160
1161 // Download a file in the Incognito window and wait. 1161 // Download a file in the Incognito window and wait.
1162 CreateAndSetDownloadsDirectory(incognito); 1162 CreateAndSetDownloadsDirectory(incognito);
1163 FilePath file(FILE_PATH_LITERAL("download-test1.lib")); 1163 FilePath file(FILE_PATH_LITERAL("download-test1.lib"));
1164 GURL url(URLRequestMockHTTPJob::GetMockUrl(file)); 1164 GURL url(URLRequestMockHTTPJob::GetMockUrl(file));
1165 // Since |incognito| is a separate browser, we have to set it up explicitly. 1165 // Since |incognito| is a separate browser, we have to set it up explicitly.
1166 incognito->profile()->GetPrefs()->SetBoolean(prefs::kPromptForDownload, 1166 incognito->profile()->GetPrefs()->SetBoolean(prefs::kPromptForDownload,
1167 false); 1167 false);
1168 DownloadAndWait(incognito, url); 1168 DownloadAndWait(incognito, url);
(...skipping 1228 matching lines...) Expand 10 before | Expand all | Expand 10 after
2397 browser()->tab_strip_model()->GetActiveWebContents(); 2397 browser()->tab_strip_model()->GetActiveWebContents();
2398 scoped_ptr<DownloadUrlParameters> params( 2398 scoped_ptr<DownloadUrlParameters> params(
2399 DownloadUrlParameters::FromWebContents(web_contents, url)); 2399 DownloadUrlParameters::FromWebContents(web_contents, url));
2400 params->set_callback(base::Bind(&SetHiddenDownloadCallback)); 2400 params->set_callback(base::Bind(&SetHiddenDownloadCallback));
2401 download_manager->DownloadUrl(params.Pass()); 2401 download_manager->DownloadUrl(params.Pass());
2402 observer->WaitForFinished(); 2402 observer->WaitForFinished();
2403 2403
2404 // Verify that download shelf is not shown. 2404 // Verify that download shelf is not shown.
2405 EXPECT_FALSE(browser()->window()->IsDownloadShelfVisible()); 2405 EXPECT_FALSE(browser()->window()->IsDownloadShelfVisible());
2406 } 2406 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698