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

Side by Side Diff: chrome/browser/ui/browser_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 <string> 5 #include <string>
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/compiler_specific.h" 8 #include "base/compiler_specific.h"
9 #include "base/file_path.h" 9 #include "base/file_path.h"
10 #include "base/sys_info.h" 10 #include "base/sys_info.h"
(...skipping 15 matching lines...) Expand all
26 #include "chrome/browser/sessions/session_service_factory.h" 26 #include "chrome/browser/sessions/session_service_factory.h"
27 #include "chrome/browser/translate/translate_tab_helper.h" 27 #include "chrome/browser/translate/translate_tab_helper.h"
28 #include "chrome/browser/ui/app_modal_dialogs/app_modal_dialog.h" 28 #include "chrome/browser/ui/app_modal_dialogs/app_modal_dialog.h"
29 #include "chrome/browser/ui/app_modal_dialogs/javascript_app_modal_dialog.h" 29 #include "chrome/browser/ui/app_modal_dialogs/javascript_app_modal_dialog.h"
30 #include "chrome/browser/ui/app_modal_dialogs/native_app_modal_dialog.h" 30 #include "chrome/browser/ui/app_modal_dialogs/native_app_modal_dialog.h"
31 #include "chrome/browser/ui/browser.h" 31 #include "chrome/browser/ui/browser.h"
32 #include "chrome/browser/ui/browser_command_controller.h" 32 #include "chrome/browser/ui/browser_command_controller.h"
33 #include "chrome/browser/ui/browser_commands.h" 33 #include "chrome/browser/ui/browser_commands.h"
34 #include "chrome/browser/ui/browser_finder.h" 34 #include "chrome/browser/ui/browser_finder.h"
35 #include "chrome/browser/ui/browser_iterator.h" 35 #include "chrome/browser/ui/browser_iterator.h"
36 #include "chrome/browser/ui/browser_list.h"
37 #include "chrome/browser/ui/browser_navigator.h" 36 #include "chrome/browser/ui/browser_navigator.h"
38 #include "chrome/browser/ui/browser_tabstrip.h" 37 #include "chrome/browser/ui/browser_tabstrip.h"
39 #include "chrome/browser/ui/browser_ui_prefs.h" 38 #include "chrome/browser/ui/browser_ui_prefs.h"
40 #include "chrome/browser/ui/browser_window.h" 39 #include "chrome/browser/ui/browser_window.h"
41 #include "chrome/browser/ui/extensions/application_launch.h" 40 #include "chrome/browser/ui/extensions/application_launch.h"
42 #include "chrome/browser/ui/startup/startup_browser_creator.h" 41 #include "chrome/browser/ui/startup/startup_browser_creator.h"
43 #include "chrome/browser/ui/startup/startup_browser_creator_impl.h" 42 #include "chrome/browser/ui/startup/startup_browser_creator_impl.h"
44 #include "chrome/browser/ui/tabs/pinned_tab_codec.h" 43 #include "chrome/browser/ui/tabs/pinned_tab_codec.h"
45 #include "chrome/browser/ui/tabs/tab_strip_model.h" 44 #include "chrome/browser/ui/tabs/tab_strip_model.h"
46 #include "chrome/common/chrome_notification_types.h" 45 #include "chrome/common/chrome_notification_types.h"
(...skipping 409 matching lines...) Expand 10 before | Expand all | Expand 10 after
456 455
457 // Run the application event loop to completion, which will cycle the 456 // Run the application event loop to completion, which will cycle the
458 // native MessagePump on all platforms. 457 // native MessagePump on all platforms.
459 MessageLoop::current()->PostTask(FROM_HERE, MessageLoop::QuitClosure()); 458 MessageLoop::current()->PostTask(FROM_HERE, MessageLoop::QuitClosure());
460 MessageLoop::current()->Run(); 459 MessageLoop::current()->Run();
461 460
462 // Take care of any remaining Cocoa work. 461 // Take care of any remaining Cocoa work.
463 CycleRunLoops(); 462 CycleRunLoops();
464 463
465 // At this point, quit should be for real now. 464 // At this point, quit should be for real now.
466 ASSERT_EQ(0u, BrowserList::size()); 465 ASSERT_EQ(0u, chrome::GetTotalBrowserCount());
467 } 466 }
468 467
469 // A helper function that cycles the MessageLoop, and on Mac, the Cocoa run 468 // A helper function that cycles the MessageLoop, and on Mac, the Cocoa run
470 // loop. It also drains the NSAutoreleasePool. 469 // loop. It also drains the NSAutoreleasePool.
471 void CycleRunLoops() { 470 void CycleRunLoops() {
472 content::RunAllPendingInMessageLoop(); 471 content::RunAllPendingInMessageLoop();
473 #if defined(OS_MACOSX) 472 #if defined(OS_MACOSX)
474 chrome::testing::NSRunLoopRunAllPending(); 473 chrome::testing::NSRunLoopRunAllPending();
475 AutoreleasePool()->Recycle(); 474 AutoreleasePool()->Recycle();
476 #endif 475 #endif
(...skipping 1195 matching lines...) Expand 10 before | Expand all | Expand 10 after
1672 1671
1673 virtual void SetUpCommandLine(CommandLine* command_line) { 1672 virtual void SetUpCommandLine(CommandLine* command_line) {
1674 command_line->AppendSwitch(switches::kKeepAliveForTest); 1673 command_line->AppendSwitch(switches::kKeepAliveForTest);
1675 } 1674 }
1676 }; 1675 };
1677 1676
1678 IN_PROC_BROWSER_TEST_F(RunInBackgroundTest, RunInBackgroundBasicTest) { 1677 IN_PROC_BROWSER_TEST_F(RunInBackgroundTest, RunInBackgroundBasicTest) {
1679 // Close the browser window, then open a new one - the browser should keep 1678 // Close the browser window, then open a new one - the browser should keep
1680 // running. 1679 // running.
1681 Profile* profile = browser()->profile(); 1680 Profile* profile = browser()->profile();
1682 EXPECT_EQ(1u, BrowserList::size()); 1681 EXPECT_EQ(1u, chrome::GetTotalBrowserCount());
1683 content::WindowedNotificationObserver observer( 1682 content::WindowedNotificationObserver observer(
1684 chrome::NOTIFICATION_BROWSER_CLOSED, 1683 chrome::NOTIFICATION_BROWSER_CLOSED,
1685 content::Source<Browser>(browser())); 1684 content::Source<Browser>(browser()));
1686 chrome::CloseWindow(browser()); 1685 chrome::CloseWindow(browser());
1687 observer.Wait(); 1686 observer.Wait();
1688 EXPECT_EQ(0u, BrowserList::size()); 1687 EXPECT_EQ(0u, chrome::GetTotalBrowserCount());
1689 1688
1690 ui_test_utils::BrowserAddedObserver browser_added_observer; 1689 ui_test_utils::BrowserAddedObserver browser_added_observer;
1691 chrome::NewEmptyWindow(profile); 1690 chrome::NewEmptyWindow(profile);
1692 browser_added_observer.WaitForSingleNewBrowser(); 1691 browser_added_observer.WaitForSingleNewBrowser();
1693 1692
1694 EXPECT_EQ(1u, BrowserList::size()); 1693 EXPECT_EQ(1u, chrome::GetTotalBrowserCount());
1695 } 1694 }
1696 1695
1697 // Tests to ensure that the browser continues running in the background after 1696 // Tests to ensure that the browser continues running in the background after
1698 // the last window closes. 1697 // the last window closes.
1699 class NoStartupWindowTest : public BrowserTest { 1698 class NoStartupWindowTest : public BrowserTest {
1700 public: 1699 public:
1701 NoStartupWindowTest() {} 1700 NoStartupWindowTest() {}
1702 1701
1703 virtual void SetUpCommandLine(CommandLine* command_line) { 1702 virtual void SetUpCommandLine(CommandLine* command_line) {
1704 command_line->AppendSwitch(switches::kNoStartupWindow); 1703 command_line->AppendSwitch(switches::kNoStartupWindow);
1705 command_line->AppendSwitch(switches::kKeepAliveForTest); 1704 command_line->AppendSwitch(switches::kKeepAliveForTest);
1706 } 1705 }
1707 }; 1706 };
1708 1707
1709 IN_PROC_BROWSER_TEST_F(NoStartupWindowTest, NoStartupWindowBasicTest) { 1708 IN_PROC_BROWSER_TEST_F(NoStartupWindowTest, NoStartupWindowBasicTest) {
1710 // No browser window should be started by default. 1709 // No browser window should be started by default.
1711 EXPECT_EQ(0u, BrowserList::size()); 1710 EXPECT_EQ(0u, chrome::GetTotalBrowserCount());
1712 1711
1713 // Starting a browser window should work just fine. 1712 // Starting a browser window should work just fine.
1714 ui_test_utils::BrowserAddedObserver browser_added_observer; 1713 ui_test_utils::BrowserAddedObserver browser_added_observer;
1715 CreateBrowser(ProfileManager::GetDefaultProfile()); 1714 CreateBrowser(ProfileManager::GetDefaultProfile());
1716 browser_added_observer.WaitForSingleNewBrowser(); 1715 browser_added_observer.WaitForSingleNewBrowser();
1717 1716
1718 EXPECT_EQ(1u, BrowserList::size()); 1717 EXPECT_EQ(1u, chrome::GetTotalBrowserCount());
1719 } 1718 }
1720 1719
1721 // Chromeos needs to track app windows because it considers them to be part of 1720 // Chromeos needs to track app windows because it considers them to be part of
1722 // session state. 1721 // session state.
1723 #if !defined(OS_CHROMEOS) 1722 #if !defined(OS_CHROMEOS)
1724 IN_PROC_BROWSER_TEST_F(NoStartupWindowTest, DontInitSessionServiceForApps) { 1723 IN_PROC_BROWSER_TEST_F(NoStartupWindowTest, DontInitSessionServiceForApps) {
1725 Profile* profile = ProfileManager::GetDefaultProfile(); 1724 Profile* profile = ProfileManager::GetDefaultProfile();
1726 1725
1727 SessionService* session_service = 1726 SessionService* session_service =
1728 SessionServiceFactory::GetForProfile(profile); 1727 SessionServiceFactory::GetForProfile(profile);
(...skipping 255 matching lines...) Expand 10 before | Expand all | Expand 10 after
1984 RunTest(browser(), GetHrefURL(), modifiers, button, disposition); 1983 RunTest(browser(), GetHrefURL(), modifiers, button, disposition);
1985 } 1984 }
1986 1985
1987 // Shift-middle-clicks open in a foreground tab. 1986 // Shift-middle-clicks open in a foreground tab.
1988 IN_PROC_BROWSER_TEST_F(ClickModifierTest, HrefShiftMiddleClickTest) { 1987 IN_PROC_BROWSER_TEST_F(ClickModifierTest, HrefShiftMiddleClickTest) {
1989 int modifiers = WebKit::WebInputEvent::ShiftKey; 1988 int modifiers = WebKit::WebInputEvent::ShiftKey;
1990 WebKit::WebMouseEvent::Button button = WebKit::WebMouseEvent::ButtonMiddle; 1989 WebKit::WebMouseEvent::Button button = WebKit::WebMouseEvent::ButtonMiddle;
1991 WindowOpenDisposition disposition = NEW_FOREGROUND_TAB; 1990 WindowOpenDisposition disposition = NEW_FOREGROUND_TAB;
1992 RunTest(browser(), GetHrefURL(), modifiers, button, disposition); 1991 RunTest(browser(), GetHrefURL(), modifiers, button, disposition);
1993 } 1992 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698