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

Side by Side Diff: chrome/browser/lifetime/browser_close_manager_browsertest.cc

Issue 176363002: Rename Start/EndKeepAlive to Increment/DecrementKeepAliveCount (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase (rename_keep_alive) Created 6 years, 9 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 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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 <vector> 5 #include <vector>
6 6
7 #include "base/command_line.h" 7 #include "base/command_line.h"
8 #include "chrome/browser/background/background_mode_manager.h" 8 #include "chrome/browser/background/background_mode_manager.h"
9 #include "chrome/browser/browser_process.h" 9 #include "chrome/browser/browser_process.h"
10 #include "chrome/browser/browser_shutdown.h" 10 #include "chrome/browser/browser_shutdown.h"
(...skipping 859 matching lines...) Expand 10 before | Expand all | Expand 10 after
870 // Check that background mode is suspended when closing all browsers unless we 870 // Check that background mode is suspended when closing all browsers unless we
871 // are quitting and that background mode is resumed when a new browser window is 871 // are quitting and that background mode is resumed when a new browser window is
872 // opened. 872 // opened.
873 IN_PROC_BROWSER_TEST_P(BrowserCloseManagerWithBackgroundModeBrowserTest, 873 IN_PROC_BROWSER_TEST_P(BrowserCloseManagerWithBackgroundModeBrowserTest,
874 CloseAllBrowsersWithBackgroundMode) { 874 CloseAllBrowsersWithBackgroundMode) {
875 EXPECT_FALSE(IsBackgroundModeSuspended()); 875 EXPECT_FALSE(IsBackgroundModeSuspended());
876 Profile* profile = browser()->profile(); 876 Profile* profile = browser()->profile();
877 { 877 {
878 RepeatedNotificationObserver close_observer( 878 RepeatedNotificationObserver close_observer(
879 chrome::NOTIFICATION_BROWSER_CLOSED, 1); 879 chrome::NOTIFICATION_BROWSER_CLOSED, 1);
880 chrome::StartKeepAlive(); 880 chrome::IncrementKeepAliveCount();
881 chrome::CloseAllBrowsers(); 881 chrome::CloseAllBrowsers();
882 close_observer.Wait(); 882 close_observer.Wait();
883 } 883 }
884 EXPECT_FALSE(browser_shutdown::IsTryingToQuit()); 884 EXPECT_FALSE(browser_shutdown::IsTryingToQuit());
885 EXPECT_TRUE(chrome::BrowserIterator().done()); 885 EXPECT_TRUE(chrome::BrowserIterator().done());
886 EXPECT_TRUE(IsBackgroundModeSuspended()); 886 EXPECT_TRUE(IsBackgroundModeSuspended());
887 887
888 // Background mode should be resumed when a new browser window is opened. 888 // Background mode should be resumed when a new browser window is opened.
889 ui_test_utils::BrowserAddedObserver new_browser_observer; 889 ui_test_utils::BrowserAddedObserver new_browser_observer;
890 chrome::NewEmptyWindow(profile, chrome::HOST_DESKTOP_TYPE_NATIVE); 890 chrome::NewEmptyWindow(profile, chrome::HOST_DESKTOP_TYPE_NATIVE);
891 new_browser_observer.WaitForSingleNewBrowser(); 891 new_browser_observer.WaitForSingleNewBrowser();
892 chrome::EndKeepAlive(); 892 chrome::DecrementKeepAliveCount();
893 EXPECT_FALSE(IsBackgroundModeSuspended()); 893 EXPECT_FALSE(IsBackgroundModeSuspended());
894 RepeatedNotificationObserver close_observer( 894 RepeatedNotificationObserver close_observer(
895 chrome::NOTIFICATION_BROWSER_CLOSED, 1); 895 chrome::NOTIFICATION_BROWSER_CLOSED, 1);
896 896
897 // Background mode should not be suspended when quitting. 897 // Background mode should not be suspended when quitting.
898 chrome::CloseAllBrowsersAndQuit(); 898 chrome::CloseAllBrowsersAndQuit();
899 close_observer.Wait(); 899 close_observer.Wait();
900 EXPECT_TRUE(browser_shutdown::IsTryingToQuit()); 900 EXPECT_TRUE(browser_shutdown::IsTryingToQuit());
901 EXPECT_TRUE(chrome::BrowserIterator().done()); 901 EXPECT_TRUE(chrome::BrowserIterator().done());
902 EXPECT_FALSE(IsBackgroundModeSuspended()); 902 EXPECT_FALSE(IsBackgroundModeSuspended());
(...skipping 14 matching lines...) Expand all
917 EXPECT_FALSE(IsBackgroundModeSuspended()); 917 EXPECT_FALSE(IsBackgroundModeSuspended());
918 } 918 }
919 919
920 // Check that closing all browsers with no browser windows open suspends 920 // Check that closing all browsers with no browser windows open suspends
921 // background mode but does not cause Chrome to quit. 921 // background mode but does not cause Chrome to quit.
922 IN_PROC_BROWSER_TEST_P(BrowserCloseManagerWithBackgroundModeBrowserTest, 922 IN_PROC_BROWSER_TEST_P(BrowserCloseManagerWithBackgroundModeBrowserTest,
923 CloseAllBrowsersWithNoOpenBrowsersWithBackgroundMode) { 923 CloseAllBrowsersWithNoOpenBrowsersWithBackgroundMode) {
924 RepeatedNotificationObserver close_observer( 924 RepeatedNotificationObserver close_observer(
925 chrome::NOTIFICATION_BROWSER_CLOSED, 1); 925 chrome::NOTIFICATION_BROWSER_CLOSED, 1);
926 EXPECT_FALSE(IsBackgroundModeSuspended()); 926 EXPECT_FALSE(IsBackgroundModeSuspended());
927 chrome::StartKeepAlive(); 927 chrome::IncrementKeepAliveCount();
928 browser()->window()->Close(); 928 browser()->window()->Close();
929 close_observer.Wait(); 929 close_observer.Wait();
930 EXPECT_FALSE(browser_shutdown::IsTryingToQuit()); 930 EXPECT_FALSE(browser_shutdown::IsTryingToQuit());
931 EXPECT_TRUE(chrome::BrowserIterator().done()); 931 EXPECT_TRUE(chrome::BrowserIterator().done());
932 EXPECT_FALSE(IsBackgroundModeSuspended()); 932 EXPECT_FALSE(IsBackgroundModeSuspended());
933 933
934 chrome::CloseAllBrowsers(); 934 chrome::CloseAllBrowsers();
935 EXPECT_FALSE(browser_shutdown::IsTryingToQuit()); 935 EXPECT_FALSE(browser_shutdown::IsTryingToQuit());
936 EXPECT_TRUE(chrome::BrowserIterator().done()); 936 EXPECT_TRUE(chrome::BrowserIterator().done());
937 EXPECT_TRUE(IsBackgroundModeSuspended()); 937 EXPECT_TRUE(IsBackgroundModeSuspended());
938 } 938 }
939 939
940 INSTANTIATE_TEST_CASE_P(BrowserCloseManagerWithBackgroundModeBrowserTest, 940 INSTANTIATE_TEST_CASE_P(BrowserCloseManagerWithBackgroundModeBrowserTest,
941 BrowserCloseManagerWithBackgroundModeBrowserTest, 941 BrowserCloseManagerWithBackgroundModeBrowserTest,
942 testing::Bool()); 942 testing::Bool());
OLDNEW
« no previous file with comments | « chrome/browser/lifetime/application_lifetime_aura.cc ('k') | chrome/browser/printing/print_dialog_cloud.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698