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

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

Issue 12210067: Get rid of native-desktop-only BrowserList:: iterator methods in tests. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: merge up to r181832 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/prefs/pref_service.h" 8 #include "base/prefs/pref_service.h"
9 #include "base/stringprintf.h" 9 #include "base/stringprintf.h"
10 #include "chrome/browser/browser_process.h" 10 #include "chrome/browser/browser_process.h"
11 #include "chrome/browser/download/download_service.h" 11 #include "chrome/browser/download/download_service.h"
12 #include "chrome/browser/download/download_service_factory.h" 12 #include "chrome/browser/download/download_service_factory.h"
13 #include "chrome/browser/download/download_test_file_activity_observer.h" 13 #include "chrome/browser/download/download_test_file_activity_observer.h"
14 #include "chrome/browser/net/url_request_mock_util.h" 14 #include "chrome/browser/net/url_request_mock_util.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_iterator.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"
23 #include "chrome/common/pref_names.h" 23 #include "chrome/common/pref_names.h"
24 #include "chrome/common/url_constants.h" 24 #include "chrome/common/url_constants.h"
25 #include "chrome/test/base/in_process_browser_test.h" 25 #include "chrome/test/base/in_process_browser_test.h"
26 #include "chrome/test/base/ui_test_utils.h" 26 #include "chrome/test/base/ui_test_utils.h"
27 #include "content/public/browser/download_item.h" 27 #include "content/public/browser/download_item.h"
28 #include "content/public/common/page_transition_types.h" 28 #include "content/public/common/page_transition_types.h"
(...skipping 175 matching lines...) Expand 10 before | Expand all | Expand 10 after
204 // num_windows > 0 204 // num_windows > 0
205 Profile* profile((*base_browser)->profile()); 205 Profile* profile((*base_browser)->profile());
206 for (int w = 1; w < num_windows; ++w) { 206 for (int w = 1; w < num_windows; ++w) {
207 CreateBrowserOnProfile(profile); 207 CreateBrowserOnProfile(profile);
208 } 208 }
209 return true; 209 return true;
210 } 210 }
211 211
212 int TotalUnclosedBrowsers() { 212 int TotalUnclosedBrowsers() {
213 int count = 0; 213 int count = 0;
214 for (BrowserList::const_iterator iter = BrowserList::begin(); 214 for (chrome::BrowserIterator it; !it.done(); it.Next()) {
215 iter != BrowserList::end(); ++iter) 215 if (!it->IsAttemptingToCloseBrowser())
216 if (!(*iter)->IsAttemptingToCloseBrowser()) {
217 count++; 216 count++;
218 } 217 }
219 return count; 218 return count;
220 } 219 }
221 220
222 // Note that this is invalid to call if TotalUnclosedBrowsers() == 0. 221 // Note that this is invalid to call if TotalUnclosedBrowsers() == 0.
223 Browser* FirstUnclosedBrowser() { 222 Browser* FirstUnclosedBrowser() {
224 for (BrowserList::const_iterator iter = BrowserList::begin(); 223 for (chrome::BrowserIterator it; !it.done(); it.Next()) {
225 iter != BrowserList::end(); ++iter) 224 if (!it->IsAttemptingToCloseBrowser())
226 if (!(*iter)->IsAttemptingToCloseBrowser()) 225 return *it;
227 return (*iter); 226 }
228 return NULL; 227 return NULL;
229 } 228 }
230 229
231 bool SetupForDownloadCloseCheck() { 230 bool SetupForDownloadCloseCheck() {
232 first_profile_ = browser()->profile(); 231 first_profile_ = browser()->profile();
233 232
234 bool result = first_profile_downloads_dir_.CreateUniqueTempDir(); 233 bool result = first_profile_downloads_dir_.CreateUniqueTempDir();
235 EXPECT_TRUE(result); 234 EXPECT_TRUE(result);
236 if (!result) return false; 235 if (!result) return false;
237 first_profile_->GetPrefs()->SetFilePath( 236 first_profile_->GetPrefs()->SetFilePath(
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after
353 if (type != Browser::DOWNLOAD_CLOSE_OK) 352 if (type != Browser::DOWNLOAD_CLOSE_OK)
354 EXPECT_EQ(check_case.num_blocking, num_downloads_blocking) 353 EXPECT_EQ(check_case.num_blocking, num_downloads_blocking)
355 << "Case " << i 354 << "Case " << i
356 << ": " << check_case.DebugString(); 355 << ": " << check_case.DebugString();
357 356
358 // Release all the downloads. 357 // Release all the downloads.
359 CompleteAllDownloads(browser_to_probe); 358 CompleteAllDownloads(browser_to_probe);
360 359
361 // Create a new main window and kill everything else. 360 // Create a new main window and kill everything else.
362 entry_browser = CreateBrowserOnProfile(first_profile_); 361 entry_browser = CreateBrowserOnProfile(first_profile_);
363 for (BrowserList::const_iterator bit = BrowserList::begin(); 362 for (chrome::BrowserIterator it; !it.done(); it.Next()) {
364 bit != BrowserList::end(); ++bit) { 363 if ((*it) != entry_browser) {
365 if ((*bit) != entry_browser) { 364 if (!it->window()) {
366 EXPECT_TRUE((*bit)->window()); 365 ADD_FAILURE();
367 if (!(*bit)->window())
368 return false; 366 return false;
369 (*bit)->window()->Close(); 367 }
368 it->window()->Close();
370 } 369 }
371 } 370 }
372 content::RunAllPendingInMessageLoop(); 371 content::RunAllPendingInMessageLoop();
373 372
374 return true; 373 return true;
375 } 374 }
376 375
377 static const DownloadsCloseCheckCase download_close_check_cases[]; 376 static const DownloadsCloseCheckCase download_close_check_cases[];
378 377
379 // DownloadCloseCheck variables. 378 // DownloadCloseCheck variables.
(...skipping 177 matching lines...) Expand 10 before | Expand all | Expand 10 after
557 } 556 }
558 } 557 }
559 558
560 IN_PROC_BROWSER_TEST_F(BrowserCloseTest, MAYBE_DownloadsCloseCheck_5) { 559 IN_PROC_BROWSER_TEST_F(BrowserCloseTest, MAYBE_DownloadsCloseCheck_5) {
561 ASSERT_TRUE(SetupForDownloadCloseCheck()); 560 ASSERT_TRUE(SetupForDownloadCloseCheck());
562 for (size_t i = 5 * arraysize(download_close_check_cases) / 6; 561 for (size_t i = 5 * arraysize(download_close_check_cases) / 6;
563 i < 6 * arraysize(download_close_check_cases) / 6; ++i) { 562 i < 6 * arraysize(download_close_check_cases) / 6; ++i) {
564 ExecuteDownloadCloseCheckCase(i); 563 ExecuteDownloadCloseCheckCase(i);
565 } 564 }
566 } 565 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/browser_browsertest.cc ('k') | chrome/browser/ui/startup/startup_browser_creator_browsertest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698