| Index: chrome/browser/ui/browser_list_unittest.cc
|
| diff --git a/chrome/browser/ui/browser_list_unittest.cc b/chrome/browser/ui/browser_list_unittest.cc
|
| index ca5d26c74c4346517db1fdf2fdd3cbdb88a990eb..7cff8a5626085e8857be36e8df2406c54448dca8 100644
|
| --- a/chrome/browser/ui/browser_list_unittest.cc
|
| +++ b/chrome/browser/ui/browser_list_unittest.cc
|
| @@ -2,12 +2,19 @@
|
| // Use of this source code is governed by a BSD-style license that can be
|
| // found in the LICENSE file.
|
|
|
| +#include "chrome/browser/browser_process.h"
|
| +#include "chrome/browser/browser_shutdown.h"
|
| +#include "chrome/browser/prefs/pref_service.h"
|
| #include "chrome/browser/printing/background_printing_manager.h"
|
| +#include "chrome/browser/profiles/profile_manager.h"
|
| #include "chrome/browser/ui/browser_list.h"
|
| #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h"
|
| +#include "chrome/common/pref_names.h"
|
| #include "chrome/common/url_constants.h"
|
| #include "chrome/test/base/browser_with_test_window_test.h"
|
| #include "chrome/test/base/testing_browser_process.h"
|
| +#include "chrome/test/base/testing_pref_service.h"
|
| +#include "chrome/test/base/testing_profile_manager.h"
|
| #include "content/browser/tab_contents/tab_contents.h"
|
|
|
| typedef BrowserWithTestWindowTest BrowserListTest;
|
| @@ -232,3 +239,33 @@ TEST_F(BrowserListTest, TabContentsIteratorBackgroundPrinting) {
|
| EXPECT_EQ(0U, CountAllTabs());
|
| }
|
| #endif
|
| +
|
| +#if defined(OS_CHROMEOS)
|
| +// Calling AttemptRestart on ChromeOS will exit the test.
|
| +#define MAYBE_AttemptRestart DISABLED_AttemptRestart
|
| +#else
|
| +#define MAYBE_AttemptRestart AttemptRestart
|
| +#endif
|
| +
|
| +TEST_F(BrowserListTest, MAYBE_AttemptRestart) {
|
| + ASSERT_TRUE(g_browser_process);
|
| + TestingPrefService testing_pref_service;
|
| + testing_pref_service.RegisterBooleanPref(prefs::kWasRestarted, false);
|
| + testing_pref_service.RegisterBooleanPref(prefs::kRestartLastSessionOnShutdown,
|
| + false);
|
| +
|
| + TestingBrowserProcess* testing_browser_process =
|
| + static_cast<TestingBrowserProcess*>(g_browser_process);
|
| + testing_browser_process->SetLocalState(&testing_pref_service);
|
| + ASSERT_TRUE(g_browser_process->local_state());
|
| + ProfileManager* profile_manager = new ProfileManager(FilePath());
|
| + testing_browser_process->SetProfileManager(profile_manager);
|
| +
|
| + BrowserList::AttemptRestart();
|
| + // Cancel the effects of us calling BrowserList::AttemptRestart. Otherwise
|
| + // tests ran after this one will fail.
|
| + browser_shutdown::SetTryingToQuit(false);
|
| +
|
| + EXPECT_TRUE(testing_pref_service.GetBoolean(prefs::kWasRestarted));
|
| + testing_browser_process->SetLocalState(NULL);
|
| +}
|
|
|