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/prefs/pref_service.h" | 9 #include "base/prefs/pref_service.h" |
| 10 #include "base/synchronization/waitable_event.h" |
10 #include "base/version.h" | 11 #include "base/version.h" |
11 #include "chrome/browser/chrome_notification_types.h" | 12 #include "chrome/browser/chrome_notification_types.h" |
12 #include "chrome/browser/profiles/chrome_version_service.h" | 13 #include "chrome/browser/profiles/chrome_version_service.h" |
13 #include "chrome/browser/profiles/profile_impl.h" | 14 #include "chrome/browser/profiles/profile_impl.h" |
14 #include "chrome/browser/profiles/startup_task_runner_service.h" | 15 #include "chrome/browser/profiles/startup_task_runner_service.h" |
15 #include "chrome/browser/profiles/startup_task_runner_service_factory.h" | 16 #include "chrome/browser/profiles/startup_task_runner_service_factory.h" |
16 #include "chrome/common/chrome_constants.h" | 17 #include "chrome/common/chrome_constants.h" |
17 #include "chrome/common/chrome_version_info.h" | 18 #include "chrome/common/chrome_version_info.h" |
18 #include "chrome/common/pref_names.h" | 19 #include "chrome/common/pref_names.h" |
19 #include "chrome/test/base/in_process_browser_test.h" | 20 #include "chrome/test/base/in_process_browser_test.h" |
20 #include "chrome/test/base/ui_test_utils.h" | 21 #include "chrome/test/base/ui_test_utils.h" |
21 #include "testing/gmock/include/gmock/gmock.h" | 22 #include "testing/gmock/include/gmock/gmock.h" |
22 #include "testing/gtest/include/gtest/gtest.h" | 23 #include "testing/gtest/include/gtest/gtest.h" |
23 | 24 |
24 namespace { | 25 namespace { |
25 | 26 |
26 class MockProfileDelegate : public Profile::Delegate { | 27 class MockProfileDelegate : public Profile::Delegate { |
27 public: | 28 public: |
28 MOCK_METHOD1(OnPrefsLoaded, void(Profile*)); | 29 MOCK_METHOD1(OnPrefsLoaded, void(Profile*)); |
29 MOCK_METHOD3(OnProfileCreated, void(Profile*, bool, bool)); | 30 MOCK_METHOD3(OnProfileCreated, void(Profile*, bool, bool)); |
30 }; | 31 }; |
31 | 32 |
32 // Creates a prefs file in the given directory. | 33 // Creates a prefs file in the given directory. |
33 void CreatePrefsFileInDirectory(const base::FilePath& directory_path) { | 34 void CreatePrefsFileInDirectory(const base::FilePath& directory_path) { |
34 base::FilePath pref_path(directory_path.Append(chrome::kPreferencesFilename)); | 35 base::FilePath pref_path(directory_path.Append(chrome::kPreferencesFilename)); |
35 std::string data("{}"); | 36 std::string data("{}"); |
36 ASSERT_TRUE(base::WriteFile(pref_path, data.c_str(), data.size())); | 37 ASSERT_TRUE(base::WriteFile(pref_path, data.c_str(), data.size())); |
37 } | 38 } |
38 | 39 |
| 40 scoped_ptr<Profile> CreateProfile( |
| 41 const base::FilePath& path, |
| 42 Profile::Delegate* delegate, |
| 43 Profile::CreateMode create_mode) { |
| 44 scoped_ptr<Profile> profile(Profile::CreateProfile( |
| 45 path, delegate, create_mode)); |
| 46 EXPECT_TRUE(profile.get()); |
| 47 // This is necessary to avoid a memleak from BookmarkModel::Load. |
| 48 // Unfortunately, this also results in warnings during debug runs. |
| 49 StartupTaskRunnerServiceFactory::GetForProfile(profile.get())-> |
| 50 StartDeferredTaskRunners(); |
| 51 return profile.Pass(); |
| 52 } |
| 53 |
39 void CheckChromeVersion(Profile *profile, bool is_new) { | 54 void CheckChromeVersion(Profile *profile, bool is_new) { |
40 std::string created_by_version; | 55 std::string created_by_version; |
41 if (is_new) { | 56 if (is_new) { |
42 chrome::VersionInfo version_info; | 57 chrome::VersionInfo version_info; |
43 created_by_version = version_info.Version(); | 58 created_by_version = version_info.Version(); |
44 } else { | 59 } else { |
45 created_by_version = "1.0.0.0"; | 60 created_by_version = "1.0.0.0"; |
46 } | 61 } |
47 std::string pref_version = | 62 std::string pref_version = |
48 ChromeVersionService::GetVersion(profile->GetPrefs()); | 63 ChromeVersionService::GetVersion(profile->GetPrefs()); |
49 // Assert that created_by_version pref gets set to current version. | 64 // Assert that created_by_version pref gets set to current version. |
50 EXPECT_EQ(created_by_version, pref_version); | 65 EXPECT_EQ(created_by_version, pref_version); |
51 } | 66 } |
52 | 67 |
| 68 void BlockThread( |
| 69 base::WaitableEvent* is_blocked, |
| 70 base::WaitableEvent* unblock) { |
| 71 is_blocked->Signal(); |
| 72 unblock->Wait(); |
| 73 } |
| 74 |
| 75 void SpinThreads() { |
| 76 // Give threads a chance to do their stuff before shutting down (i.e. |
| 77 // deleting scoped temp dir etc). |
| 78 // Should not be necessary anymore once Profile deletion is fixed |
| 79 // (see crbug.com/88586). |
| 80 content::RunAllPendingInMessageLoop(); |
| 81 content::RunAllPendingInMessageLoop(content::BrowserThread::DB); |
| 82 content::RunAllPendingInMessageLoop(content::BrowserThread::FILE); |
| 83 } |
| 84 |
53 } // namespace | 85 } // namespace |
54 | 86 |
55 typedef InProcessBrowserTest ProfileBrowserTest; | 87 typedef InProcessBrowserTest ProfileBrowserTest; |
56 | 88 |
57 // Test OnProfileCreate is called with is_new_profile set to true when | 89 // Test OnProfileCreate is called with is_new_profile set to true when |
58 // creating a new profile synchronously. | 90 // creating a new profile synchronously. |
59 // | 91 // |
60 // Flaky (sometimes timeout): http://crbug.com/141141 | 92 // Flaky (sometimes timeout): http://crbug.com/141141 |
61 IN_PROC_BROWSER_TEST_F(ProfileBrowserTest, | 93 IN_PROC_BROWSER_TEST_F(ProfileBrowserTest, |
62 DISABLED_CreateNewProfileSynchronous) { | 94 DISABLED_CreateNewProfileSynchronous) { |
63 base::ScopedTempDir temp_dir; | 95 base::ScopedTempDir temp_dir; |
64 ASSERT_TRUE(temp_dir.CreateUniqueTempDir()); | 96 ASSERT_TRUE(temp_dir.CreateUniqueTempDir()); |
65 | 97 |
66 MockProfileDelegate delegate; | 98 MockProfileDelegate delegate; |
67 EXPECT_CALL(delegate, OnProfileCreated(testing::NotNull(), true, true)); | 99 EXPECT_CALL(delegate, OnProfileCreated(testing::NotNull(), true, true)); |
68 | 100 |
69 scoped_ptr<Profile> profile(Profile::CreateProfile( | 101 { |
70 temp_dir.path(), &delegate, Profile::CREATE_MODE_SYNCHRONOUS)); | 102 scoped_ptr<Profile> profile(CreateProfile( |
71 ASSERT_TRUE(profile.get()); | 103 temp_dir.path(), &delegate, Profile::CREATE_MODE_SYNCHRONOUS)); |
72 CheckChromeVersion(profile.get(), true); | 104 CheckChromeVersion(profile.get(), true); |
73 StartupTaskRunnerServiceFactory::GetForProfile(profile.get())-> | 105 } |
74 StartDeferredTaskRunners(); | 106 |
| 107 SpinThreads(); |
75 } | 108 } |
76 | 109 |
77 // Test OnProfileCreate is called with is_new_profile set to false when | 110 // Test OnProfileCreate is called with is_new_profile set to false when |
78 // creating a profile synchronously with an existing prefs file. | 111 // creating a profile synchronously with an existing prefs file. |
79 // Flaky: http://crbug.com/141517 | 112 // Flaky: http://crbug.com/141517 |
80 IN_PROC_BROWSER_TEST_F(ProfileBrowserTest, | 113 IN_PROC_BROWSER_TEST_F(ProfileBrowserTest, |
81 DISABLED_CreateOldProfileSynchronous) { | 114 DISABLED_CreateOldProfileSynchronous) { |
82 base::ScopedTempDir temp_dir; | 115 base::ScopedTempDir temp_dir; |
83 ASSERT_TRUE(temp_dir.CreateUniqueTempDir()); | 116 ASSERT_TRUE(temp_dir.CreateUniqueTempDir()); |
84 CreatePrefsFileInDirectory(temp_dir.path()); | 117 CreatePrefsFileInDirectory(temp_dir.path()); |
85 | 118 |
86 MockProfileDelegate delegate; | 119 MockProfileDelegate delegate; |
87 EXPECT_CALL(delegate, OnProfileCreated(testing::NotNull(), true, false)); | 120 EXPECT_CALL(delegate, OnProfileCreated(testing::NotNull(), true, false)); |
88 | 121 |
89 scoped_ptr<Profile> profile(Profile::CreateProfile( | 122 { |
90 temp_dir.path(), &delegate, Profile::CREATE_MODE_SYNCHRONOUS)); | 123 scoped_ptr<Profile> profile(CreateProfile( |
91 ASSERT_TRUE(profile.get()); | 124 temp_dir.path(), &delegate, Profile::CREATE_MODE_SYNCHRONOUS)); |
92 CheckChromeVersion(profile.get(), false); | 125 CheckChromeVersion(profile.get(), false); |
93 StartupTaskRunnerServiceFactory::GetForProfile(profile.get())-> | 126 } |
94 StartDeferredTaskRunners(); | 127 |
| 128 SpinThreads(); |
95 } | 129 } |
96 | 130 |
97 // Test OnProfileCreate is called with is_new_profile set to true when | 131 // Test OnProfileCreate is called with is_new_profile set to true when |
98 // creating a new profile asynchronously. | 132 // creating a new profile asynchronously. |
99 // This test is flaky on Linux, Win and Mac. See crbug.com/142787 | 133 // This test is flaky on Linux, Win and Mac. See crbug.com/142787 |
100 IN_PROC_BROWSER_TEST_F(ProfileBrowserTest, | 134 IN_PROC_BROWSER_TEST_F(ProfileBrowserTest, |
101 DISABLED_CreateNewProfileAsynchronous) { | 135 DISABLED_CreateNewProfileAsynchronous) { |
102 base::ScopedTempDir temp_dir; | 136 base::ScopedTempDir temp_dir; |
103 ASSERT_TRUE(temp_dir.CreateUniqueTempDir()); | 137 ASSERT_TRUE(temp_dir.CreateUniqueTempDir()); |
104 | 138 |
105 MockProfileDelegate delegate; | 139 MockProfileDelegate delegate; |
106 EXPECT_CALL(delegate, OnProfileCreated(testing::NotNull(), true, true)); | 140 EXPECT_CALL(delegate, OnProfileCreated(testing::NotNull(), true, true)); |
107 | 141 |
108 scoped_ptr<Profile> profile(Profile::CreateProfile( | 142 { |
109 temp_dir.path(), &delegate, Profile::CREATE_MODE_ASYNCHRONOUS)); | 143 content::WindowedNotificationObserver observer( |
110 ASSERT_TRUE(profile.get()); | 144 chrome::NOTIFICATION_PROFILE_CREATED, |
111 StartupTaskRunnerServiceFactory::GetForProfile(profile.get())-> | 145 content::NotificationService::AllSources()); |
112 StartDeferredTaskRunners(); | |
113 | 146 |
114 // Wait for the profile to be created. | 147 scoped_ptr<Profile> profile(CreateProfile( |
115 content::WindowedNotificationObserver observer( | 148 temp_dir.path(), &delegate, Profile::CREATE_MODE_ASYNCHRONOUS)); |
116 chrome::NOTIFICATION_PROFILE_CREATED, | 149 |
117 content::Source<Profile>(profile.get())); | 150 // Wait for the profile to be created. |
118 observer.Wait(); | 151 observer.Wait(); |
119 CheckChromeVersion(profile.get(), true); | 152 CheckChromeVersion(profile.get(), true); |
| 153 } |
| 154 |
| 155 SpinThreads(); |
120 } | 156 } |
121 | 157 |
122 // Test OnProfileCreate is called with is_new_profile set to false when | 158 // Test OnProfileCreate is called with is_new_profile set to false when |
123 // creating a profile asynchronously with an existing prefs file. | 159 // creating a profile asynchronously with an existing prefs file. |
124 // Flaky: http://crbug.com/141517 | 160 // Flaky: http://crbug.com/141517 |
125 IN_PROC_BROWSER_TEST_F(ProfileBrowserTest, | 161 IN_PROC_BROWSER_TEST_F(ProfileBrowserTest, |
126 DISABLED_CreateOldProfileAsynchronous) { | 162 DISABLED_CreateOldProfileAsynchronous) { |
127 base::ScopedTempDir temp_dir; | 163 base::ScopedTempDir temp_dir; |
128 ASSERT_TRUE(temp_dir.CreateUniqueTempDir()); | 164 ASSERT_TRUE(temp_dir.CreateUniqueTempDir()); |
129 CreatePrefsFileInDirectory(temp_dir.path()); | 165 CreatePrefsFileInDirectory(temp_dir.path()); |
130 | 166 |
131 MockProfileDelegate delegate; | 167 MockProfileDelegate delegate; |
132 EXPECT_CALL(delegate, OnProfileCreated(testing::NotNull(), true, false)); | 168 EXPECT_CALL(delegate, OnProfileCreated(testing::NotNull(), true, false)); |
133 scoped_ptr<Profile> profile(Profile::CreateProfile( | |
134 temp_dir.path(), &delegate, Profile::CREATE_MODE_ASYNCHRONOUS)); | |
135 ASSERT_TRUE(profile.get()); | |
136 StartupTaskRunnerServiceFactory::GetForProfile(profile.get())-> | |
137 StartDeferredTaskRunners(); | |
138 | 169 |
139 // Wait for the profile to be created. | 170 { |
140 content::WindowedNotificationObserver observer( | 171 content::WindowedNotificationObserver observer( |
141 chrome::NOTIFICATION_PROFILE_CREATED, | 172 chrome::NOTIFICATION_PROFILE_CREATED, |
142 content::Source<Profile>(profile.get())); | 173 content::NotificationService::AllSources()); |
143 observer.Wait(); | 174 |
144 CheckChromeVersion(profile.get(), false); | 175 scoped_ptr<Profile> profile(CreateProfile( |
| 176 temp_dir.path(), &delegate, Profile::CREATE_MODE_ASYNCHRONOUS)); |
| 177 |
| 178 // Wait for the profile to be created. |
| 179 observer.Wait(); |
| 180 CheckChromeVersion(profile.get(), false); |
| 181 } |
| 182 |
| 183 SpinThreads(); |
145 } | 184 } |
146 | 185 |
147 // Test that a README file is created for profiles that didn't have it. | 186 // Test that a README file is created for profiles that didn't have it. |
148 // Flaky: http://crbug.com/140882 | 187 // Flaky: http://crbug.com/140882 |
149 IN_PROC_BROWSER_TEST_F(ProfileBrowserTest, DISABLED_ProfileReadmeCreated) { | 188 IN_PROC_BROWSER_TEST_F(ProfileBrowserTest, DISABLED_ProfileReadmeCreated) { |
150 base::ScopedTempDir temp_dir; | 189 base::ScopedTempDir temp_dir; |
151 ASSERT_TRUE(temp_dir.CreateUniqueTempDir()); | 190 ASSERT_TRUE(temp_dir.CreateUniqueTempDir()); |
152 | 191 |
153 MockProfileDelegate delegate; | 192 MockProfileDelegate delegate; |
154 EXPECT_CALL(delegate, OnProfileCreated(testing::NotNull(), true, true)); | 193 EXPECT_CALL(delegate, OnProfileCreated(testing::NotNull(), true, true)); |
155 | 194 |
156 // No delay before README creation. | 195 // No delay before README creation. |
157 ProfileImpl::create_readme_delay_ms = 0; | 196 ProfileImpl::create_readme_delay_ms = 0; |
158 | 197 |
159 scoped_ptr<Profile> profile(Profile::CreateProfile( | 198 { |
160 temp_dir.path(), &delegate, Profile::CREATE_MODE_ASYNCHRONOUS)); | 199 content::WindowedNotificationObserver observer( |
161 ASSERT_TRUE(profile.get()); | 200 chrome::NOTIFICATION_PROFILE_CREATED, |
162 StartupTaskRunnerServiceFactory::GetForProfile(profile.get())-> | 201 content::NotificationService::AllSources()); |
163 StartDeferredTaskRunners(); | |
164 | 202 |
165 // Wait for the profile to be created. | 203 scoped_ptr<Profile> profile(CreateProfile( |
166 content::WindowedNotificationObserver observer( | 204 temp_dir.path(), &delegate, Profile::CREATE_MODE_ASYNCHRONOUS)); |
167 chrome::NOTIFICATION_PROFILE_CREATED, | |
168 content::Source<Profile>(profile.get())); | |
169 observer.Wait(); | |
170 | 205 |
171 content::RunAllPendingInMessageLoop(content::BrowserThread::FILE); | 206 // Wait for the profile to be created. |
| 207 observer.Wait(); |
172 | 208 |
173 // Verify that README exists. | 209 // Wait for file thread to create the README. |
174 EXPECT_TRUE(base::PathExists( | 210 content::RunAllPendingInMessageLoop(content::BrowserThread::FILE); |
175 temp_dir.path().Append(chrome::kReadmeFilename))); | 211 |
| 212 // Verify that README exists. |
| 213 EXPECT_TRUE(base::PathExists( |
| 214 temp_dir.path().Append(chrome::kReadmeFilename))); |
| 215 } |
| 216 |
| 217 SpinThreads(); |
176 } | 218 } |
177 | 219 |
178 // Test that Profile can be deleted before README file is created. | 220 // Test that Profile can be deleted before README file is created. |
179 IN_PROC_BROWSER_TEST_F(ProfileBrowserTest, ProfileDeletedBeforeReadmeCreated) { | 221 IN_PROC_BROWSER_TEST_F(ProfileBrowserTest, ProfileDeletedBeforeReadmeCreated) { |
180 base::ScopedTempDir temp_dir; | 222 base::ScopedTempDir temp_dir; |
181 ASSERT_TRUE(temp_dir.CreateUniqueTempDir()); | 223 ASSERT_TRUE(temp_dir.CreateUniqueTempDir()); |
182 | 224 |
183 MockProfileDelegate delegate; | 225 MockProfileDelegate delegate; |
184 EXPECT_CALL(delegate, OnProfileCreated(testing::NotNull(), true, true)); | 226 EXPECT_CALL(delegate, OnProfileCreated(testing::NotNull(), true, true)); |
185 | 227 |
186 // No delay before README creation. | 228 // No delay before README creation. |
187 ProfileImpl::create_readme_delay_ms = 0; | 229 ProfileImpl::create_readme_delay_ms = 0; |
188 | 230 |
189 scoped_ptr<Profile> profile(Profile::CreateProfile( | 231 base::WaitableEvent is_blocked(false, false); |
| 232 base::WaitableEvent* unblock = new base::WaitableEvent(false, false); |
| 233 |
| 234 // Block file thread. |
| 235 content::BrowserThread::PostTask( |
| 236 content::BrowserThread::FILE, FROM_HERE, |
| 237 base::Bind(&BlockThread, &is_blocked, base::Owned(unblock))); |
| 238 // Wait for file thread to actually be blocked. |
| 239 is_blocked.Wait(); |
| 240 |
| 241 scoped_ptr<Profile> profile(CreateProfile( |
190 temp_dir.path(), &delegate, Profile::CREATE_MODE_SYNCHRONOUS)); | 242 temp_dir.path(), &delegate, Profile::CREATE_MODE_SYNCHRONOUS)); |
191 ASSERT_TRUE(profile.get()); | |
192 StartupTaskRunnerServiceFactory::GetForProfile(profile.get())-> | |
193 StartDeferredTaskRunners(); | |
194 | 243 |
195 // Delete the Profile instance and run pending tasks (this includes the task | 244 // Delete the Profile instance before we give the file thread a chance to |
196 // for README creation). | 245 // create the README. |
197 profile.reset(); | 246 profile.reset(); |
198 content::RunAllPendingInMessageLoop(); | 247 |
199 content::RunAllPendingInMessageLoop(content::BrowserThread::DB); | 248 // Now unblock the file thread again and run pending tasks (this includes the |
200 content::RunAllPendingInMessageLoop(content::BrowserThread::FILE); | 249 // task for README creation). |
| 250 unblock->Signal(); |
| 251 |
| 252 SpinThreads(); |
201 } | 253 } |
202 | 254 |
203 // Test that repeated setting of exit type is handled correctly. | 255 // Test that repeated setting of exit type is handled correctly. |
204 #if defined(OS_WIN) | 256 #if defined(OS_WIN) |
205 // Flaky on Windows: http://crbug.com/163713 | 257 // Flaky on Windows: http://crbug.com/163713 |
206 #define MAYBE_ExitType DISABLED_ExitType | 258 #define MAYBE_ExitType DISABLED_ExitType |
207 #else | 259 #else |
208 #define MAYBE_ExitType ExitType | 260 #define MAYBE_ExitType ExitType |
209 #endif | 261 #endif |
210 IN_PROC_BROWSER_TEST_F(ProfileBrowserTest, MAYBE_ExitType) { | 262 IN_PROC_BROWSER_TEST_F(ProfileBrowserTest, MAYBE_ExitType) { |
211 base::ScopedTempDir temp_dir; | 263 base::ScopedTempDir temp_dir; |
212 ASSERT_TRUE(temp_dir.CreateUniqueTempDir()); | 264 ASSERT_TRUE(temp_dir.CreateUniqueTempDir()); |
213 | 265 |
214 MockProfileDelegate delegate; | 266 MockProfileDelegate delegate; |
215 EXPECT_CALL(delegate, OnProfileCreated(testing::NotNull(), true, true)); | 267 EXPECT_CALL(delegate, OnProfileCreated(testing::NotNull(), true, true)); |
| 268 { |
| 269 scoped_ptr<Profile> profile(CreateProfile( |
| 270 temp_dir.path(), &delegate, Profile::CREATE_MODE_SYNCHRONOUS)); |
216 | 271 |
217 scoped_ptr<Profile> profile(Profile::CreateProfile( | 272 PrefService* prefs = profile->GetPrefs(); |
218 temp_dir.path(), &delegate, Profile::CREATE_MODE_SYNCHRONOUS)); | 273 // The initial state is crashed; store for later reference. |
219 ASSERT_TRUE(profile.get()); | 274 std::string crash_value(prefs->GetString(prefs::kSessionExitType)); |
220 StartupTaskRunnerServiceFactory::GetForProfile(profile.get())-> | |
221 StartDeferredTaskRunners(); | |
222 | 275 |
223 PrefService* prefs = profile->GetPrefs(); | 276 // The first call to a type other than crashed should change the value. |
224 // The initial state is crashed; store for later reference. | 277 profile->SetExitType(Profile::EXIT_SESSION_ENDED); |
225 std::string crash_value(prefs->GetString(prefs::kSessionExitType)); | 278 std::string first_call_value(prefs->GetString(prefs::kSessionExitType)); |
| 279 EXPECT_NE(crash_value, first_call_value); |
226 | 280 |
227 // The first call to a type other than crashed should change the value. | 281 // Subsequent calls to a non-crash value should be ignored. |
228 profile->SetExitType(Profile::EXIT_SESSION_ENDED); | 282 profile->SetExitType(Profile::EXIT_NORMAL); |
229 std::string first_call_value(prefs->GetString(prefs::kSessionExitType)); | 283 std::string second_call_value(prefs->GetString(prefs::kSessionExitType)); |
230 EXPECT_NE(crash_value, first_call_value); | 284 EXPECT_EQ(first_call_value, second_call_value); |
231 | 285 |
232 // Subsequent calls to a non-crash value should be ignored. | 286 // Setting back to a crashed value should work. |
233 profile->SetExitType(Profile::EXIT_NORMAL); | 287 profile->SetExitType(Profile::EXIT_CRASHED); |
234 std::string second_call_value(prefs->GetString(prefs::kSessionExitType)); | 288 std::string final_value(prefs->GetString(prefs::kSessionExitType)); |
235 EXPECT_EQ(first_call_value, second_call_value); | 289 EXPECT_EQ(crash_value, final_value); |
| 290 } |
236 | 291 |
237 // Setting back to a crashed value should work. | 292 SpinThreads(); |
238 profile->SetExitType(Profile::EXIT_CRASHED); | |
239 std::string final_value(prefs->GetString(prefs::kSessionExitType)); | |
240 EXPECT_EQ(crash_value, final_value); | |
241 | |
242 // This test runs fast enough that the WebDataService may still be | |
243 // initializing (which uses the temp directory) when the test | |
244 // ends. Give it a chance to complete. | |
245 profile.reset(); | |
246 content::RunAllPendingInMessageLoop(); | |
247 content::RunAllPendingInMessageLoop(content::BrowserThread::DB); | |
248 } | 293 } |
OLD | NEW |