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

Side by Side Diff: chrome/test/base/in_process_browser_test.cc

Issue 12211139: Phase out BrowserList::empty() and BrowserList::size(). (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix chromeos 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 "chrome/test/base/in_process_browser_test.h" 5 #include "chrome/test/base/in_process_browser_test.h"
6 6
7 #include "base/auto_reset.h" 7 #include "base/auto_reset.h"
8 #include "base/bind.h" 8 #include "base/bind.h"
9 #include "base/command_line.h" 9 #include "base/command_line.h"
10 #include "base/file_path.h" 10 #include "base/file_path.h"
11 #include "base/file_util.h" 11 #include "base/file_util.h"
12 #include "base/lazy_instance.h" 12 #include "base/lazy_instance.h"
13 #include "base/path_service.h" 13 #include "base/path_service.h"
14 #include "base/strings/string_number_conversions.h" 14 #include "base/strings/string_number_conversions.h"
15 #include "base/test/test_file_util.h" 15 #include "base/test/test_file_util.h"
16 #include "chrome/browser/browser_process.h" 16 #include "chrome/browser/browser_process.h"
17 #include "chrome/browser/google/google_util.h" 17 #include "chrome/browser/google/google_util.h"
18 #include "chrome/browser/io_thread.h" 18 #include "chrome/browser/io_thread.h"
19 #include "chrome/browser/lifetime/application_lifetime.h" 19 #include "chrome/browser/lifetime/application_lifetime.h"
20 #include "chrome/browser/net/net_error_tab_helper.h" 20 #include "chrome/browser/net/net_error_tab_helper.h"
21 #include "chrome/browser/profiles/profile.h" 21 #include "chrome/browser/profiles/profile.h"
22 #include "chrome/browser/profiles/profile_manager.h" 22 #include "chrome/browser/profiles/profile_manager.h"
23 #include "chrome/browser/ui/browser.h" 23 #include "chrome/browser/ui/browser.h"
24 #include "chrome/browser/ui/browser_list.h" 24 #include "chrome/browser/ui/browser_finder.h"
25 #include "chrome/browser/ui/browser_list_impl.h" 25 #include "chrome/browser/ui/browser_list_impl.h"
26 #include "chrome/browser/ui/browser_navigator.h" 26 #include "chrome/browser/ui/browser_navigator.h"
27 #include "chrome/browser/ui/browser_tabstrip.h" 27 #include "chrome/browser/ui/browser_tabstrip.h"
28 #include "chrome/browser/ui/browser_window.h" 28 #include "chrome/browser/ui/browser_window.h"
29 #include "chrome/browser/ui/host_desktop.h" 29 #include "chrome/browser/ui/host_desktop.h"
30 #include "chrome/browser/ui/tabs/tab_strip_model.h" 30 #include "chrome/browser/ui/tabs/tab_strip_model.h"
31 #include "chrome/common/chrome_constants.h" 31 #include "chrome/common/chrome_constants.h"
32 #include "chrome/common/chrome_paths.h" 32 #include "chrome/common/chrome_paths.h"
33 #include "chrome/common/chrome_switches.h" 33 #include "chrome/common/chrome_switches.h"
34 #include "chrome/common/logging_chrome.h" 34 #include "chrome/common/logging_chrome.h"
(...skipping 329 matching lines...) Expand 10 before | Expand all | Expand 10 after
364 autorelease_pool_->Recycle(); 364 autorelease_pool_->Recycle();
365 #endif 365 #endif
366 366
367 // Sometimes tests leave Quit tasks in the MessageLoop (for shame), so let's 367 // Sometimes tests leave Quit tasks in the MessageLoop (for shame), so let's
368 // run all pending messages here to avoid preempting the QuitBrowsers tasks. 368 // run all pending messages here to avoid preempting the QuitBrowsers tasks.
369 // TODO(jbates) Once crbug.com/134753 is fixed, this can be removed because it 369 // TODO(jbates) Once crbug.com/134753 is fixed, this can be removed because it
370 // will not be possible to post Quit tasks. 370 // will not be possible to post Quit tasks.
371 content::RunAllPendingInMessageLoop(); 371 content::RunAllPendingInMessageLoop();
372 372
373 QuitBrowsers(); 373 QuitBrowsers();
374 CHECK(BrowserList::empty()); 374 CHECK(native_browser_list->empty());
375 } 375 }
376 376
377 void InProcessBrowserTest::QuitBrowsers() { 377 void InProcessBrowserTest::QuitBrowsers() {
378 if (BrowserList::empty()) 378 if (chrome::GetTotalBrowserCount() == 0)
379 return; 379 return;
380 380
381 // Invoke AttemptExit on a running message loop. 381 // Invoke AttemptExit on a running message loop.
382 // AttemptExit exits the message loop after everything has been 382 // AttemptExit exits the message loop after everything has been
383 // shut down properly. 383 // shut down properly.
384 MessageLoopForUI::current()->PostTask(FROM_HERE, 384 MessageLoopForUI::current()->PostTask(FROM_HERE,
385 base::Bind(&browser::AttemptExit)); 385 base::Bind(&browser::AttemptExit));
386 content::RunMessageLoop(); 386 content::RunMessageLoop();
387 387
388 #if defined(OS_MACOSX) 388 #if defined(OS_MACOSX)
389 // browser::AttemptExit() will attempt to close all browsers by deleting 389 // browser::AttemptExit() will attempt to close all browsers by deleting
390 // their tab contents. The last tab contents being removed triggers closing of 390 // their tab contents. The last tab contents being removed triggers closing of
391 // the browser window. 391 // the browser window.
392 // 392 //
393 // On the Mac, this eventually reaches 393 // On the Mac, this eventually reaches
394 // -[BrowserWindowController windowWillClose:], which will post a deferred 394 // -[BrowserWindowController windowWillClose:], which will post a deferred
395 // -autorelease on itself to ultimately destroy the Browser object. The line 395 // -autorelease on itself to ultimately destroy the Browser object. The line
396 // below is necessary to pump these pending messages to ensure all Browsers 396 // below is necessary to pump these pending messages to ensure all Browsers
397 // get deleted. 397 // get deleted.
398 content::RunAllPendingInMessageLoop(); 398 content::RunAllPendingInMessageLoop();
399 delete autorelease_pool_; 399 delete autorelease_pool_;
400 autorelease_pool_ = NULL; 400 autorelease_pool_ = NULL;
401 #endif 401 #endif
402 } 402 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/cocoa/one_click_signin_dialog_controller_browsertest.mm ('k') | chrome/test/base/ui_test_utils.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698