| OLD | NEW |
| 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 Loading... |
| 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 Loading... |
| 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()); |
| OLD | NEW |