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