| OLD | NEW |
| 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/browser/ui/tab_contents/tab_contents_iterator.h" | 5 #include "chrome/browser/ui/tab_contents/tab_contents_iterator.h" |
| 6 | 6 |
| 7 #include "chrome/browser/browser_process.h" | 7 #include "chrome/browser/browser_process.h" |
| 8 #include "chrome/browser/browser_shutdown.h" | 8 #include "chrome/browser/browser_shutdown.h" |
| 9 #include "chrome/browser/prefs/pref_registry_simple.h" |
| 9 #include "chrome/browser/profiles/profile_manager.h" | 10 #include "chrome/browser/profiles/profile_manager.h" |
| 10 #include "chrome/browser/ui/browser_commands.h" | 11 #include "chrome/browser/ui/browser_commands.h" |
| 11 #include "chrome/browser/ui/browser_list.h" | 12 #include "chrome/browser/ui/browser_list.h" |
| 12 #include "chrome/browser/ui/tabs/tab_strip_model.h" | 13 #include "chrome/browser/ui/tabs/tab_strip_model.h" |
| 13 #include "chrome/common/pref_names.h" | 14 #include "chrome/common/pref_names.h" |
| 14 #include "chrome/test/base/browser_with_test_window_test.h" | 15 #include "chrome/test/base/browser_with_test_window_test.h" |
| 15 #include "chrome/test/base/test_browser_window.h" | 16 #include "chrome/test/base/test_browser_window.h" |
| 16 #include "chrome/test/base/testing_browser_process.h" | 17 #include "chrome/test/base/testing_browser_process.h" |
| 17 #include "chrome/test/base/testing_pref_service.h" | 18 #include "chrome/test/base/testing_pref_service.h" |
| 18 | 19 |
| (...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 145 #if defined(OS_CHROMEOS) | 146 #if defined(OS_CHROMEOS) |
| 146 // Calling AttemptRestart on ChromeOS will exit the test. | 147 // Calling AttemptRestart on ChromeOS will exit the test. |
| 147 #define MAYBE_AttemptRestart DISABLED_AttemptRestart | 148 #define MAYBE_AttemptRestart DISABLED_AttemptRestart |
| 148 #else | 149 #else |
| 149 #define MAYBE_AttemptRestart AttemptRestart | 150 #define MAYBE_AttemptRestart AttemptRestart |
| 150 #endif | 151 #endif |
| 151 | 152 |
| 152 TEST_F(BrowserListTest, MAYBE_AttemptRestart) { | 153 TEST_F(BrowserListTest, MAYBE_AttemptRestart) { |
| 153 ASSERT_TRUE(g_browser_process); | 154 ASSERT_TRUE(g_browser_process); |
| 154 TestingPrefServiceSimple testing_pref_service; | 155 TestingPrefServiceSimple testing_pref_service; |
| 155 testing_pref_service.RegisterBooleanPref(prefs::kWasRestarted, false); | 156 testing_pref_service.registry()->RegisterBooleanPref( |
| 156 testing_pref_service.RegisterBooleanPref(prefs::kRestartLastSessionOnShutdown, | 157 prefs::kWasRestarted, false); |
| 157 false); | 158 testing_pref_service.registry()->RegisterBooleanPref( |
| 159 prefs::kRestartLastSessionOnShutdown, |
| 160 false); |
| 158 | 161 |
| 159 TestingBrowserProcess* testing_browser_process = | 162 TestingBrowserProcess* testing_browser_process = |
| 160 TestingBrowserProcess::GetGlobal(); | 163 TestingBrowserProcess::GetGlobal(); |
| 161 testing_browser_process->SetLocalState(&testing_pref_service); | 164 testing_browser_process->SetLocalState(&testing_pref_service); |
| 162 ASSERT_TRUE(g_browser_process->local_state()); | 165 ASSERT_TRUE(g_browser_process->local_state()); |
| 163 ProfileManager* profile_manager = new ProfileManager(FilePath()); | 166 ProfileManager* profile_manager = new ProfileManager(FilePath()); |
| 164 testing_browser_process->SetProfileManager(profile_manager); | 167 testing_browser_process->SetProfileManager(profile_manager); |
| 165 | 168 |
| 166 browser::AttemptRestart(); | 169 browser::AttemptRestart(); |
| 167 // Cancel the effects of us calling browser::AttemptRestart. Otherwise tests | 170 // Cancel the effects of us calling browser::AttemptRestart. Otherwise tests |
| 168 // ran after this one will fail. | 171 // ran after this one will fail. |
| 169 browser_shutdown::SetTryingToQuit(false); | 172 browser_shutdown::SetTryingToQuit(false); |
| 170 | 173 |
| 171 EXPECT_TRUE(testing_pref_service.GetBoolean(prefs::kWasRestarted)); | 174 EXPECT_TRUE(testing_pref_service.GetBoolean(prefs::kWasRestarted)); |
| 172 testing_browser_process->SetLocalState(NULL); | 175 testing_browser_process->SetLocalState(NULL); |
| 173 } | 176 } |
| OLD | NEW |