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/profiles/profile.h" | 5 #include "chrome/browser/profiles/profile.h" |
6 | 6 |
7 #include "base/file_util.h" | 7 #include "base/file_util.h" |
8 #include "base/files/scoped_temp_dir.h" | 8 #include "base/files/scoped_temp_dir.h" |
9 #include "base/platform_file.h" | 9 #include "base/platform_file.h" |
10 #include "base/version.h" | 10 #include "base/version.h" |
(...skipping 172 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
183 ASSERT_TRUE(profile.get()); | 183 ASSERT_TRUE(profile.get()); |
184 | 184 |
185 // Delete the Profile instance and run pending tasks (this includes the task | 185 // Delete the Profile instance and run pending tasks (this includes the task |
186 // for README creation). | 186 // for README creation). |
187 profile.reset(); | 187 profile.reset(); |
188 content::RunAllPendingInMessageLoop(); | 188 content::RunAllPendingInMessageLoop(); |
189 content::RunAllPendingInMessageLoop(content::BrowserThread::FILE); | 189 content::RunAllPendingInMessageLoop(content::BrowserThread::FILE); |
190 } | 190 } |
191 | 191 |
192 // Test that repeated setting of exit type is handled correctly. | 192 // Test that repeated setting of exit type is handled correctly. |
193 IN_PROC_BROWSER_TEST_F(ProfileBrowserTest, ExitType) { | 193 #if defined(OS_WIN) |
| 194 // Flaky on Windows: http://crbug.com/163713 |
| 195 #define MAYBE_ExitType DISABLED_ExitType |
| 196 #else |
| 197 #define MAYBE_ExitType ExitType |
| 198 #endif |
| 199 IN_PROC_BROWSER_TEST_F(ProfileBrowserTest, MAYBE_ExitType) { |
194 base::ScopedTempDir temp_dir; | 200 base::ScopedTempDir temp_dir; |
195 ASSERT_TRUE(temp_dir.CreateUniqueTempDir()); | 201 ASSERT_TRUE(temp_dir.CreateUniqueTempDir()); |
196 | 202 |
197 MockProfileDelegate delegate; | 203 MockProfileDelegate delegate; |
198 EXPECT_CALL(delegate, OnProfileCreated(testing::NotNull(), true, true)); | 204 EXPECT_CALL(delegate, OnProfileCreated(testing::NotNull(), true, true)); |
199 | 205 |
200 scoped_ptr<Profile> profile(Profile::CreateProfile( | 206 scoped_ptr<Profile> profile(Profile::CreateProfile( |
201 temp_dir.path(), &delegate, Profile::CREATE_MODE_SYNCHRONOUS)); | 207 temp_dir.path(), &delegate, Profile::CREATE_MODE_SYNCHRONOUS)); |
202 ASSERT_TRUE(profile.get()); | 208 ASSERT_TRUE(profile.get()); |
203 | 209 |
204 PrefService* prefs = profile->GetPrefs(); | 210 PrefService* prefs = profile->GetPrefs(); |
205 // The initial state is crashed; store for later reference. | 211 // The initial state is crashed; store for later reference. |
206 std::string crash_value(prefs->GetString(prefs::kSessionExitType)); | 212 std::string crash_value(prefs->GetString(prefs::kSessionExitType)); |
207 | 213 |
208 // The first call to a type other than crashed should change the value. | 214 // The first call to a type other than crashed should change the value. |
209 profile->SetExitType(Profile::EXIT_SESSION_ENDED); | 215 profile->SetExitType(Profile::EXIT_SESSION_ENDED); |
210 std::string first_call_value(prefs->GetString(prefs::kSessionExitType)); | 216 std::string first_call_value(prefs->GetString(prefs::kSessionExitType)); |
211 EXPECT_NE(crash_value, first_call_value); | 217 EXPECT_NE(crash_value, first_call_value); |
212 | 218 |
213 // Subsequent calls to a non-crash value should be ignored. | 219 // Subsequent calls to a non-crash value should be ignored. |
214 profile->SetExitType(Profile::EXIT_NORMAL); | 220 profile->SetExitType(Profile::EXIT_NORMAL); |
215 std::string second_call_value(prefs->GetString(prefs::kSessionExitType)); | 221 std::string second_call_value(prefs->GetString(prefs::kSessionExitType)); |
216 EXPECT_EQ(first_call_value, second_call_value); | 222 EXPECT_EQ(first_call_value, second_call_value); |
217 | 223 |
218 // Setting back to a crashed value should work. | 224 // Setting back to a crashed value should work. |
219 profile->SetExitType(Profile::EXIT_CRASHED); | 225 profile->SetExitType(Profile::EXIT_CRASHED); |
220 std::string final_value(prefs->GetString(prefs::kSessionExitType)); | 226 std::string final_value(prefs->GetString(prefs::kSessionExitType)); |
221 EXPECT_EQ(crash_value, final_value); | 227 EXPECT_EQ(crash_value, final_value); |
222 } | 228 } |
OLD | NEW |