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_impl.h" | 12 #include "chrome/browser/ui/browser_list_impl.h" |
12 #include "chrome/browser/ui/host_desktop.h" | 13 #include "chrome/browser/ui/host_desktop.h" |
13 #include "chrome/browser/ui/tabs/tab_strip_model.h" | 14 #include "chrome/browser/ui/tabs/tab_strip_model.h" |
14 #include "chrome/common/pref_names.h" | 15 #include "chrome/common/pref_names.h" |
15 #include "chrome/test/base/browser_with_test_window_test.h" | 16 #include "chrome/test/base/browser_with_test_window_test.h" |
16 #include "chrome/test/base/test_browser_window.h" | 17 #include "chrome/test/base/test_browser_window.h" |
17 #include "chrome/test/base/testing_browser_process.h" | 18 #include "chrome/test/base/testing_browser_process.h" |
18 #include "chrome/test/base/testing_pref_service.h" | 19 #include "chrome/test/base/testing_pref_service.h" |
(...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
174 #if defined(OS_CHROMEOS) | 175 #if defined(OS_CHROMEOS) |
175 // Calling AttemptRestart on ChromeOS will exit the test. | 176 // Calling AttemptRestart on ChromeOS will exit the test. |
176 #define MAYBE_AttemptRestart DISABLED_AttemptRestart | 177 #define MAYBE_AttemptRestart DISABLED_AttemptRestart |
177 #else | 178 #else |
178 #define MAYBE_AttemptRestart AttemptRestart | 179 #define MAYBE_AttemptRestart AttemptRestart |
179 #endif | 180 #endif |
180 | 181 |
181 TEST_F(BrowserListTest, MAYBE_AttemptRestart) { | 182 TEST_F(BrowserListTest, MAYBE_AttemptRestart) { |
182 ASSERT_TRUE(g_browser_process); | 183 ASSERT_TRUE(g_browser_process); |
183 TestingPrefServiceSimple testing_pref_service; | 184 TestingPrefServiceSimple testing_pref_service; |
184 testing_pref_service.RegisterBooleanPref(prefs::kWasRestarted, false); | 185 testing_pref_service.registry()->RegisterBooleanPref( |
185 testing_pref_service.RegisterBooleanPref(prefs::kRestartLastSessionOnShutdown, | 186 prefs::kWasRestarted, false); |
186 false); | 187 testing_pref_service.registry()->RegisterBooleanPref( |
| 188 prefs::kRestartLastSessionOnShutdown, |
| 189 false); |
187 | 190 |
188 TestingBrowserProcess* testing_browser_process = | 191 TestingBrowserProcess* testing_browser_process = |
189 TestingBrowserProcess::GetGlobal(); | 192 TestingBrowserProcess::GetGlobal(); |
190 testing_browser_process->SetLocalState(&testing_pref_service); | 193 testing_browser_process->SetLocalState(&testing_pref_service); |
191 ASSERT_TRUE(g_browser_process->local_state()); | 194 ASSERT_TRUE(g_browser_process->local_state()); |
192 ProfileManager* profile_manager = new ProfileManager(FilePath()); | 195 ProfileManager* profile_manager = new ProfileManager(FilePath()); |
193 testing_browser_process->SetProfileManager(profile_manager); | 196 testing_browser_process->SetProfileManager(profile_manager); |
194 | 197 |
195 browser::AttemptRestart(); | 198 browser::AttemptRestart(); |
196 // Cancel the effects of us calling browser::AttemptRestart. Otherwise tests | 199 // Cancel the effects of us calling browser::AttemptRestart. Otherwise tests |
197 // ran after this one will fail. | 200 // ran after this one will fail. |
198 browser_shutdown::SetTryingToQuit(false); | 201 browser_shutdown::SetTryingToQuit(false); |
199 | 202 |
200 EXPECT_TRUE(testing_pref_service.GetBoolean(prefs::kWasRestarted)); | 203 EXPECT_TRUE(testing_pref_service.GetBoolean(prefs::kWasRestarted)); |
201 testing_browser_process->SetLocalState(NULL); | 204 testing_browser_process->SetLocalState(NULL); |
202 } | 205 } |
OLD | NEW |