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 123 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
142 #if defined(OS_CHROMEOS) | 143 #if defined(OS_CHROMEOS) |
143 // Calling AttemptRestart on ChromeOS will exit the test. | 144 // Calling AttemptRestart on ChromeOS will exit the test. |
144 #define MAYBE_AttemptRestart DISABLED_AttemptRestart | 145 #define MAYBE_AttemptRestart DISABLED_AttemptRestart |
145 #else | 146 #else |
146 #define MAYBE_AttemptRestart AttemptRestart | 147 #define MAYBE_AttemptRestart AttemptRestart |
147 #endif | 148 #endif |
148 | 149 |
149 TEST_F(BrowserListTest, MAYBE_AttemptRestart) { | 150 TEST_F(BrowserListTest, MAYBE_AttemptRestart) { |
150 ASSERT_TRUE(g_browser_process); | 151 ASSERT_TRUE(g_browser_process); |
151 TestingPrefServiceSimple testing_pref_service; | 152 TestingPrefServiceSimple testing_pref_service; |
152 testing_pref_service.RegisterBooleanPref(prefs::kWasRestarted, false); | 153 testing_pref_service.registry()->RegisterBooleanPref( |
153 testing_pref_service.RegisterBooleanPref(prefs::kRestartLastSessionOnShutdown, | 154 prefs::kWasRestarted, false); |
154 false); | 155 testing_pref_service.registry()->RegisterBooleanPref( |
| 156 prefs::kRestartLastSessionOnShutdown, |
| 157 false); |
155 | 158 |
156 TestingBrowserProcess* testing_browser_process = | 159 TestingBrowserProcess* testing_browser_process = |
157 TestingBrowserProcess::GetGlobal(); | 160 TestingBrowserProcess::GetGlobal(); |
158 testing_browser_process->SetLocalState(&testing_pref_service); | 161 testing_browser_process->SetLocalState(&testing_pref_service); |
159 ASSERT_TRUE(g_browser_process->local_state()); | 162 ASSERT_TRUE(g_browser_process->local_state()); |
160 ProfileManager* profile_manager = new ProfileManager(FilePath()); | 163 ProfileManager* profile_manager = new ProfileManager(FilePath()); |
161 testing_browser_process->SetProfileManager(profile_manager); | 164 testing_browser_process->SetProfileManager(profile_manager); |
162 | 165 |
163 browser::AttemptRestart(); | 166 browser::AttemptRestart(); |
164 // Cancel the effects of us calling browser::AttemptRestart. Otherwise tests | 167 // Cancel the effects of us calling browser::AttemptRestart. Otherwise tests |
165 // ran after this one will fail. | 168 // ran after this one will fail. |
166 browser_shutdown::SetTryingToQuit(false); | 169 browser_shutdown::SetTryingToQuit(false); |
167 | 170 |
168 EXPECT_TRUE(testing_pref_service.GetBoolean(prefs::kWasRestarted)); | 171 EXPECT_TRUE(testing_pref_service.GetBoolean(prefs::kWasRestarted)); |
169 testing_browser_process->SetLocalState(NULL); | 172 testing_browser_process->SetLocalState(NULL); |
170 } | 173 } |
OLD | NEW |