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

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: Rename to DownloadTestFileActivityObserver Created 7 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) 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/common/chrome_paths.h" 21 #include "chrome/common/chrome_paths.h"
22 #include "chrome/common/pref_names.h" 22 #include "chrome/common/pref_names.h"
(...skipping 210 matching lines...) Expand 10 before | Expand all | Expand 10 after
233 EXPECT_TRUE(result); 233 EXPECT_TRUE(result);
234 if (!result) return false; 234 if (!result) return false;
235 first_profile_->GetPrefs()->SetFilePath( 235 first_profile_->GetPrefs()->SetFilePath(
236 prefs::kDownloadDefaultDirectory, 236 prefs::kDownloadDefaultDirectory,
237 first_profile_downloads_dir_.path()); 237 first_profile_downloads_dir_.path());
238 238
239 second_profile_ = CreateSecondProfile(); 239 second_profile_ = CreateSecondProfile();
240 EXPECT_TRUE(second_profile_); 240 EXPECT_TRUE(second_profile_);
241 if (!second_profile_) return false; 241 if (!second_profile_) return false;
242 242
243 DownloadTestFileChooserObserver(first_profile_) .EnableFileChooser(false); 243 DownloadTestFileActivityObserver(first_profile_) .EnableFileChooser(false);
244 DownloadTestFileChooserObserver(second_profile_).EnableFileChooser(false); 244 DownloadTestFileActivityObserver(second_profile_).EnableFileChooser(false);
245 return true; 245 return true;
246 } 246 }
247 247
248 // Test a specific DownloadsCloseCheckCase. Returns false if 248 // Test a specific DownloadsCloseCheckCase. Returns false if
249 // an assertion has failed and the test should be aborted. 249 // an assertion has failed and the test should be aborted.
250 bool ExecuteDownloadCloseCheckCase(size_t i) { 250 bool ExecuteDownloadCloseCheckCase(size_t i) {
251 const DownloadsCloseCheckCase& check_case(download_close_check_cases[i]); 251 const DownloadsCloseCheckCase& check_case(download_close_check_cases[i]);
252 252
253 // Test invariant: so that we don't actually try and close the browser, 253 // Test invariant: so that we don't actually try and close the browser,
254 // we always enter the function with a single browser window open on the 254 // we always enter the function with a single browser window open on the
(...skipping 17 matching lines...) Expand all
272 int total_download_count = DownloadService::DownloadCountAllProfiles(); 272 int total_download_count = DownloadService::DownloadCountAllProfiles();
273 EXPECT_EQ(0, total_download_count) 273 EXPECT_EQ(0, total_download_count)
274 << "Case " << i 274 << "Case " << i
275 << ": " << check_case.DebugString(); 275 << ": " << check_case.DebugString();
276 if (0 != total_download_count) 276 if (0 != total_download_count)
277 return false; 277 return false;
278 278
279 Profile* first_profile_incognito = first_profile_->GetOffTheRecordProfile(); 279 Profile* first_profile_incognito = first_profile_->GetOffTheRecordProfile();
280 Profile* second_profile_incognito = 280 Profile* second_profile_incognito =
281 second_profile_->GetOffTheRecordProfile(); 281 second_profile_->GetOffTheRecordProfile();
282 DownloadTestFileChooserObserver(first_profile_incognito) 282 DownloadTestFileActivityObserver(first_profile_incognito)
283 .EnableFileChooser(false); 283 .EnableFileChooser(false);
284 DownloadTestFileChooserObserver(second_profile_incognito) 284 DownloadTestFileActivityObserver(second_profile_incognito)
285 .EnableFileChooser(false); 285 .EnableFileChooser(false);
286 286
287 // For simplicty of coding, we create a window on each profile so that 287 // For simplicty of coding, we create a window on each profile so that
288 // we can easily create downloads, then we destroy or create windows 288 // we can easily create downloads, then we destroy or create windows
289 // as necessary. 289 // as necessary.
290 Browser* browser_a_regular(CreateBrowserOnProfile(first_profile_)); 290 Browser* browser_a_regular(CreateBrowserOnProfile(first_profile_));
291 Browser* browser_a_incognito( 291 Browser* browser_a_incognito(
292 CreateBrowserOnProfile(first_profile_incognito)); 292 CreateBrowserOnProfile(first_profile_incognito));
293 Browser* browser_b_regular(CreateBrowserOnProfile(second_profile_)); 293 Browser* browser_b_regular(CreateBrowserOnProfile(second_profile_));
294 Browser* browser_b_incognito( 294 Browser* browser_b_incognito(
(...skipping 260 matching lines...) Expand 10 before | Expand all | Expand 10 after
555 } 555 }
556 } 556 }
557 557
558 IN_PROC_BROWSER_TEST_F(BrowserCloseTest, MAYBE_DownloadsCloseCheck_5) { 558 IN_PROC_BROWSER_TEST_F(BrowserCloseTest, MAYBE_DownloadsCloseCheck_5) {
559 ASSERT_TRUE(SetupForDownloadCloseCheck()); 559 ASSERT_TRUE(SetupForDownloadCloseCheck());
560 for (size_t i = 5 * arraysize(download_close_check_cases) / 6; 560 for (size_t i = 5 * arraysize(download_close_check_cases) / 6;
561 i < 6 * arraysize(download_close_check_cases) / 6; ++i) { 561 i < 6 * arraysize(download_close_check_cases) / 6; ++i) {
562 ExecuteDownloadCloseCheckCase(i); 562 ExecuteDownloadCloseCheckCase(i);
563 } 563 }
564 } 564 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698