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

Side by Side Diff: chrome/browser/ui/browser_close_browsertest.cc

Issue 12047039: download: Remove DownloadManager::MockDownloadOpenForTesting (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebase and comment fix 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 "base/command_line.h" 5 #include "base/command_line.h"
6 #include "base/logging.h" 6 #include "base/logging.h"
7 #include "base/path_service.h" 7 #include "base/path_service.h"
8 #include "base/stringprintf.h" 8 #include "base/stringprintf.h"
9 #include "chrome/browser/browser_process.h" 9 #include "chrome/browser/browser_process.h"
10 #include "chrome/browser/download/download_service.h" 10 #include "chrome/browser/download/download_service.h"
11 #include "chrome/browser/download/download_service_factory.h" 11 #include "chrome/browser/download/download_service_factory.h"
12 #include "chrome/browser/download/download_test_file_chooser_observer.h" 12 #include "chrome/browser/download/download_test_file_activity_observer.h"
13 #include "chrome/browser/net/url_request_mock_util.h" 13 #include "chrome/browser/net/url_request_mock_util.h"
14 #include "chrome/browser/prefs/pref_service.h" 14 #include "chrome/browser/prefs/pref_service.h"
15 #include "chrome/browser/profiles/profile.h" 15 #include "chrome/browser/profiles/profile.h"
16 #include "chrome/browser/profiles/profile_manager.h" 16 #include "chrome/browser/profiles/profile_manager.h"
17 #include "chrome/browser/ui/browser.h" 17 #include "chrome/browser/ui/browser.h"
18 #include "chrome/browser/ui/browser_list.h" 18 #include "chrome/browser/ui/browser_list.h"
19 #include "chrome/browser/ui/browser_tabstrip.h" 19 #include "chrome/browser/ui/browser_tabstrip.h"
20 #include "chrome/browser/ui/browser_window.h" 20 #include "chrome/browser/ui/browser_window.h"
21 #include "chrome/browser/ui/tabs/tab_strip_model.h" 21 #include "chrome/browser/ui/tabs/tab_strip_model.h"
22 #include "chrome/common/chrome_paths.h" 22 #include "chrome/common/chrome_paths.h"
(...skipping 212 matching lines...) Expand 10 before | Expand all | Expand 10 after
235 EXPECT_TRUE(result); 235 EXPECT_TRUE(result);
236 if (!result) return false; 236 if (!result) return false;
237 first_profile_->GetPrefs()->SetFilePath( 237 first_profile_->GetPrefs()->SetFilePath(
238 prefs::kDownloadDefaultDirectory, 238 prefs::kDownloadDefaultDirectory,
239 first_profile_downloads_dir_.path()); 239 first_profile_downloads_dir_.path());
240 240
241 second_profile_ = CreateSecondProfile(); 241 second_profile_ = CreateSecondProfile();
242 EXPECT_TRUE(second_profile_); 242 EXPECT_TRUE(second_profile_);
243 if (!second_profile_) return false; 243 if (!second_profile_) return false;
244 244
245 DownloadTestFileChooserObserver(first_profile_) .EnableFileChooser(false); 245 DownloadTestFileActivityObserver(first_profile_) .EnableFileChooser(false);
246 DownloadTestFileChooserObserver(second_profile_).EnableFileChooser(false); 246 DownloadTestFileActivityObserver(second_profile_).EnableFileChooser(false);
247 return true; 247 return true;
248 } 248 }
249 249
250 // Test a specific DownloadsCloseCheckCase. Returns false if 250 // Test a specific DownloadsCloseCheckCase. Returns false if
251 // an assertion has failed and the test should be aborted. 251 // an assertion has failed and the test should be aborted.
252 bool ExecuteDownloadCloseCheckCase(size_t i) { 252 bool ExecuteDownloadCloseCheckCase(size_t i) {
253 const DownloadsCloseCheckCase& check_case(download_close_check_cases[i]); 253 const DownloadsCloseCheckCase& check_case(download_close_check_cases[i]);
254 254
255 // Test invariant: so that we don't actually try and close the browser, 255 // Test invariant: so that we don't actually try and close the browser,
256 // we always enter the function with a single browser window open on the 256 // we always enter the function with a single browser window open on the
(...skipping 17 matching lines...) Expand all
274 int total_download_count = DownloadService::DownloadCountAllProfiles(); 274 int total_download_count = DownloadService::DownloadCountAllProfiles();
275 EXPECT_EQ(0, total_download_count) 275 EXPECT_EQ(0, total_download_count)
276 << "Case " << i 276 << "Case " << i
277 << ": " << check_case.DebugString(); 277 << ": " << check_case.DebugString();
278 if (0 != total_download_count) 278 if (0 != total_download_count)
279 return false; 279 return false;
280 280
281 Profile* first_profile_incognito = first_profile_->GetOffTheRecordProfile(); 281 Profile* first_profile_incognito = first_profile_->GetOffTheRecordProfile();
282 Profile* second_profile_incognito = 282 Profile* second_profile_incognito =
283 second_profile_->GetOffTheRecordProfile(); 283 second_profile_->GetOffTheRecordProfile();
284 DownloadTestFileChooserObserver(first_profile_incognito) 284 DownloadTestFileActivityObserver(first_profile_incognito)
285 .EnableFileChooser(false); 285 .EnableFileChooser(false);
286 DownloadTestFileChooserObserver(second_profile_incognito) 286 DownloadTestFileActivityObserver(second_profile_incognito)
287 .EnableFileChooser(false); 287 .EnableFileChooser(false);
288 288
289 // For simplicty of coding, we create a window on each profile so that 289 // For simplicty of coding, we create a window on each profile so that
290 // we can easily create downloads, then we destroy or create windows 290 // we can easily create downloads, then we destroy or create windows
291 // as necessary. 291 // as necessary.
292 Browser* browser_a_regular(CreateBrowserOnProfile(first_profile_)); 292 Browser* browser_a_regular(CreateBrowserOnProfile(first_profile_));
293 Browser* browser_a_incognito( 293 Browser* browser_a_incognito(
294 CreateBrowserOnProfile(first_profile_incognito)); 294 CreateBrowserOnProfile(first_profile_incognito));
295 Browser* browser_b_regular(CreateBrowserOnProfile(second_profile_)); 295 Browser* browser_b_regular(CreateBrowserOnProfile(second_profile_));
296 Browser* browser_b_incognito( 296 Browser* browser_b_incognito(
(...skipping 260 matching lines...) Expand 10 before | Expand all | Expand 10 after
557 } 557 }
558 } 558 }
559 559
560 IN_PROC_BROWSER_TEST_F(BrowserCloseTest, MAYBE_DownloadsCloseCheck_5) { 560 IN_PROC_BROWSER_TEST_F(BrowserCloseTest, MAYBE_DownloadsCloseCheck_5) {
561 ASSERT_TRUE(SetupForDownloadCloseCheck()); 561 ASSERT_TRUE(SetupForDownloadCloseCheck());
562 for (size_t i = 5 * arraysize(download_close_check_cases) / 6; 562 for (size_t i = 5 * arraysize(download_close_check_cases) / 6;
563 i < 6 * arraysize(download_close_check_cases) / 6; ++i) { 563 i < 6 * arraysize(download_close_check_cases) / 6; ++i) {
564 ExecuteDownloadCloseCheckCase(i); 564 ExecuteDownloadCloseCheckCase(i);
565 } 565 }
566 } 566 }
OLDNEW
« no previous file with comments | « chrome/browser/extensions/api/downloads/downloads_api_unittest.cc ('k') | chrome/chrome_tests_unit.gypi » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698