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/command_line.h" | 7 #include "base/command_line.h" |
8 #include "base/file_util.h" | 8 #include "base/file_util.h" |
9 #include "base/files/scoped_temp_dir.h" | 9 #include "base/files/scoped_temp_dir.h" |
10 #include "base/prefs/pref_service.h" | 10 #include "base/prefs/pref_service.h" |
11 #include "base/sequenced_task_runner.h" | |
11 #include "base/synchronization/waitable_event.h" | 12 #include "base/synchronization/waitable_event.h" |
12 #include "base/version.h" | 13 #include "base/version.h" |
14 #include "chrome/browser/browser_process.h" | |
13 #include "chrome/browser/chrome_notification_types.h" | 15 #include "chrome/browser/chrome_notification_types.h" |
14 #include "chrome/browser/profiles/chrome_version_service.h" | 16 #include "chrome/browser/profiles/chrome_version_service.h" |
15 #include "chrome/browser/profiles/profile_impl.h" | 17 #include "chrome/browser/profiles/profile_impl.h" |
16 #include "chrome/browser/profiles/startup_task_runner_service.h" | 18 #include "chrome/browser/profiles/startup_task_runner_service.h" |
17 #include "chrome/browser/profiles/startup_task_runner_service_factory.h" | 19 #include "chrome/browser/profiles/startup_task_runner_service_factory.h" |
18 #include "chrome/common/chrome_constants.h" | 20 #include "chrome/common/chrome_constants.h" |
19 #include "chrome/common/chrome_version_info.h" | 21 #include "chrome/common/chrome_version_info.h" |
20 #include "chrome/common/pref_names.h" | 22 #include "chrome/common/pref_names.h" |
21 #include "chrome/test/base/in_process_browser_test.h" | 23 #include "chrome/test/base/in_process_browser_test.h" |
22 #include "chrome/test/base/ui_test_utils.h" | 24 #include "chrome/test/base/ui_test_utils.h" |
(...skipping 12 matching lines...) Expand all Loading... | |
35 MOCK_METHOD3(OnProfileCreated, void(Profile*, bool, bool)); | 37 MOCK_METHOD3(OnProfileCreated, void(Profile*, bool, bool)); |
36 }; | 38 }; |
37 | 39 |
38 // Creates a prefs file in the given directory. | 40 // Creates a prefs file in the given directory. |
39 void CreatePrefsFileInDirectory(const base::FilePath& directory_path) { | 41 void CreatePrefsFileInDirectory(const base::FilePath& directory_path) { |
40 base::FilePath pref_path(directory_path.Append(chrome::kPreferencesFilename)); | 42 base::FilePath pref_path(directory_path.Append(chrome::kPreferencesFilename)); |
41 std::string data("{}"); | 43 std::string data("{}"); |
42 ASSERT_TRUE(base::WriteFile(pref_path, data.c_str(), data.size())); | 44 ASSERT_TRUE(base::WriteFile(pref_path, data.c_str(), data.size())); |
43 } | 45 } |
44 | 46 |
45 scoped_ptr<Profile> CreateProfile( | |
46 const base::FilePath& path, | |
47 Profile::Delegate* delegate, | |
48 Profile::CreateMode create_mode) { | |
49 scoped_ptr<Profile> profile(Profile::CreateProfile( | |
50 path, delegate, create_mode)); | |
51 EXPECT_TRUE(profile.get()); | |
52 // This is necessary to avoid a memleak from BookmarkModel::Load. | |
53 // Unfortunately, this also results in warnings during debug runs. | |
gab
2014/07/03 18:56:56
As mentioned offline, make sure ASAN bots pass and
| |
54 StartupTaskRunnerServiceFactory::GetForProfile(profile.get())-> | |
55 StartDeferredTaskRunners(); | |
56 return profile.Pass(); | |
57 } | |
58 | |
59 void CheckChromeVersion(Profile *profile, bool is_new) { | 47 void CheckChromeVersion(Profile *profile, bool is_new) { |
60 std::string created_by_version; | 48 std::string created_by_version; |
61 if (is_new) { | 49 if (is_new) { |
62 chrome::VersionInfo version_info; | 50 chrome::VersionInfo version_info; |
63 created_by_version = version_info.Version(); | 51 created_by_version = version_info.Version(); |
64 } else { | 52 } else { |
65 created_by_version = "1.0.0.0"; | 53 created_by_version = "1.0.0.0"; |
66 } | 54 } |
67 std::string pref_version = | 55 std::string pref_version = |
68 ChromeVersionService::GetVersion(profile->GetPrefs()); | 56 ChromeVersionService::GetVersion(profile->GetPrefs()); |
69 // Assert that created_by_version pref gets set to current version. | 57 // Assert that created_by_version pref gets set to current version. |
70 EXPECT_EQ(created_by_version, pref_version); | 58 EXPECT_EQ(created_by_version, pref_version); |
71 } | 59 } |
72 | 60 |
73 void BlockThread( | 61 void BlockThread( |
74 base::WaitableEvent* is_blocked, | 62 base::WaitableEvent* is_blocked, |
75 base::WaitableEvent* unblock) { | 63 base::WaitableEvent* unblock) { |
76 is_blocked->Signal(); | 64 is_blocked->Signal(); |
77 unblock->Wait(); | 65 unblock->Wait(); |
78 } | 66 } |
79 | 67 |
68 void FlushTaskRunner(base::SequencedTaskRunner* runner) { | |
69 base::WaitableEvent unblock(false, false); | |
70 | |
71 runner->PostTask(FROM_HERE, | |
72 base::Bind(&base::WaitableEvent::Signal, base::Unretained(&unblock))); | |
73 | |
74 unblock.Wait(); | |
75 } | |
76 | |
80 void SpinThreads() { | 77 void SpinThreads() { |
81 // Give threads a chance to do their stuff before shutting down (i.e. | 78 // Give threads a chance to do their stuff before shutting down (i.e. |
82 // deleting scoped temp dir etc). | 79 // deleting scoped temp dir etc). |
83 // Should not be necessary anymore once Profile deletion is fixed | 80 // Should not be necessary anymore once Profile deletion is fixed |
84 // (see crbug.com/88586). | 81 // (see crbug.com/88586). |
85 content::RunAllPendingInMessageLoop(); | 82 content::RunAllPendingInMessageLoop(); |
86 content::RunAllPendingInMessageLoop(content::BrowserThread::DB); | 83 content::RunAllPendingInMessageLoop(content::BrowserThread::DB); |
87 content::RunAllPendingInMessageLoop(content::BrowserThread::FILE); | 84 content::RunAllPendingInMessageLoop(content::BrowserThread::FILE); |
88 } | 85 } |
89 | 86 |
90 } // namespace | 87 } // namespace |
91 | 88 |
92 class ProfileBrowserTest : public InProcessBrowserTest { | 89 class ProfileBrowserTest : public InProcessBrowserTest { |
93 protected: | 90 protected: |
94 virtual void SetUpCommandLine(CommandLine* command_line) OVERRIDE { | 91 virtual void SetUpCommandLine(CommandLine* command_line) OVERRIDE { |
95 #if defined(OS_CHROMEOS) | 92 #if defined(OS_CHROMEOS) |
96 command_line->AppendSwitch( | 93 command_line->AppendSwitch( |
97 chromeos::switches::kIgnoreUserProfileMappingForTests); | 94 chromeos::switches::kIgnoreUserProfileMappingForTests); |
98 #endif | 95 #endif |
99 } | 96 } |
97 | |
98 scoped_ptr<Profile> CreateProfile( | |
99 const base::FilePath& path, | |
100 Profile::Delegate* delegate, | |
101 Profile::CreateMode create_mode) { | |
102 scoped_ptr<Profile> profile(Profile::CreateProfile( | |
103 path, delegate, create_mode)); | |
104 EXPECT_TRUE(profile.get()); | |
105 | |
106 // Store the Profile's IO task runner so we can wind it down. | |
107 profile_io_task_runner_ = profile->GetIOTaskRunner(); | |
108 | |
109 return profile.Pass(); | |
110 } | |
111 | |
112 void FlushIoTaskRunnerAndSpinThreads() { | |
113 FlushTaskRunner(profile_io_task_runner_); | |
114 | |
115 SpinThreads(); | |
116 } | |
117 | |
118 scoped_refptr<base::SequencedTaskRunner> profile_io_task_runner_; | |
100 }; | 119 }; |
101 | 120 |
102 // Test OnProfileCreate is called with is_new_profile set to true when | 121 // Test OnProfileCreate is called with is_new_profile set to true when |
103 // creating a new profile synchronously. | 122 // creating a new profile synchronously. |
104 // | 123 IN_PROC_BROWSER_TEST_F(ProfileBrowserTest, CreateNewProfileSynchronous) { |
105 // Flaky (sometimes timeout): http://crbug.com/141141 | |
106 IN_PROC_BROWSER_TEST_F(ProfileBrowserTest, | |
107 DISABLED_CreateNewProfileSynchronous) { | |
108 base::ScopedTempDir temp_dir; | 124 base::ScopedTempDir temp_dir; |
109 ASSERT_TRUE(temp_dir.CreateUniqueTempDir()); | 125 ASSERT_TRUE(temp_dir.CreateUniqueTempDir()); |
110 | 126 |
111 MockProfileDelegate delegate; | 127 MockProfileDelegate delegate; |
112 EXPECT_CALL(delegate, OnProfileCreated(testing::NotNull(), true, true)); | 128 EXPECT_CALL(delegate, OnProfileCreated(testing::NotNull(), true, true)); |
113 | 129 |
114 { | 130 { |
115 scoped_ptr<Profile> profile(CreateProfile( | 131 scoped_ptr<Profile> profile(CreateProfile( |
116 temp_dir.path(), &delegate, Profile::CREATE_MODE_SYNCHRONOUS)); | 132 temp_dir.path(), &delegate, Profile::CREATE_MODE_SYNCHRONOUS)); |
117 CheckChromeVersion(profile.get(), true); | 133 CheckChromeVersion(profile.get(), true); |
118 } | 134 } |
119 | 135 |
120 SpinThreads(); | 136 FlushIoTaskRunnerAndSpinThreads(); |
noms (inactive)
2014/07/03 18:07:11
Is this used by every test? Could it go in the Tea
Sigurður Ásgeirsson
2014/07/03 18:14:46
Sadly no, the last test has different rundown requ
noms (inactive)
2014/07/03 18:23:42
Ah, I see. Thanks!
On 2014/07/03 18:14:46, Sigurð
| |
121 } | 137 } |
122 | 138 |
123 // Test OnProfileCreate is called with is_new_profile set to false when | 139 // Test OnProfileCreate is called with is_new_profile set to false when |
124 // creating a profile synchronously with an existing prefs file. | 140 // creating a profile synchronously with an existing prefs file. |
125 // Flaky: http://crbug.com/141517 | 141 IN_PROC_BROWSER_TEST_F(ProfileBrowserTest, CreateOldProfileSynchronous) { |
126 IN_PROC_BROWSER_TEST_F(ProfileBrowserTest, | |
127 DISABLED_CreateOldProfileSynchronous) { | |
128 base::ScopedTempDir temp_dir; | 142 base::ScopedTempDir temp_dir; |
129 ASSERT_TRUE(temp_dir.CreateUniqueTempDir()); | 143 ASSERT_TRUE(temp_dir.CreateUniqueTempDir()); |
130 CreatePrefsFileInDirectory(temp_dir.path()); | 144 CreatePrefsFileInDirectory(temp_dir.path()); |
131 | 145 |
132 MockProfileDelegate delegate; | 146 MockProfileDelegate delegate; |
133 EXPECT_CALL(delegate, OnProfileCreated(testing::NotNull(), true, false)); | 147 EXPECT_CALL(delegate, OnProfileCreated(testing::NotNull(), true, false)); |
134 | 148 |
135 { | 149 { |
136 scoped_ptr<Profile> profile(CreateProfile( | 150 scoped_ptr<Profile> profile(CreateProfile( |
137 temp_dir.path(), &delegate, Profile::CREATE_MODE_SYNCHRONOUS)); | 151 temp_dir.path(), &delegate, Profile::CREATE_MODE_SYNCHRONOUS)); |
138 CheckChromeVersion(profile.get(), false); | 152 CheckChromeVersion(profile.get(), false); |
139 } | 153 } |
140 | 154 |
141 SpinThreads(); | 155 FlushIoTaskRunnerAndSpinThreads(); |
142 } | 156 } |
143 | 157 |
144 // Test OnProfileCreate is called with is_new_profile set to true when | 158 // Test OnProfileCreate is called with is_new_profile set to true when |
145 // creating a new profile asynchronously. | 159 // creating a new profile asynchronously. |
146 // This test is flaky on Linux, Win and Mac. See crbug.com/142787 | 160 IN_PROC_BROWSER_TEST_F(ProfileBrowserTest, CreateNewProfileAsynchronous) { |
147 IN_PROC_BROWSER_TEST_F(ProfileBrowserTest, | |
148 DISABLED_CreateNewProfileAsynchronous) { | |
149 base::ScopedTempDir temp_dir; | 161 base::ScopedTempDir temp_dir; |
150 ASSERT_TRUE(temp_dir.CreateUniqueTempDir()); | 162 ASSERT_TRUE(temp_dir.CreateUniqueTempDir()); |
151 | 163 |
152 MockProfileDelegate delegate; | 164 MockProfileDelegate delegate; |
153 EXPECT_CALL(delegate, OnProfileCreated(testing::NotNull(), true, true)); | 165 EXPECT_CALL(delegate, OnProfileCreated(testing::NotNull(), true, true)); |
154 | 166 |
155 { | 167 { |
156 content::WindowedNotificationObserver observer( | 168 content::WindowedNotificationObserver observer( |
157 chrome::NOTIFICATION_PROFILE_CREATED, | 169 chrome::NOTIFICATION_PROFILE_CREATED, |
158 content::NotificationService::AllSources()); | 170 content::NotificationService::AllSources()); |
159 | 171 |
160 scoped_ptr<Profile> profile(CreateProfile( | 172 scoped_ptr<Profile> profile(CreateProfile( |
161 temp_dir.path(), &delegate, Profile::CREATE_MODE_ASYNCHRONOUS)); | 173 temp_dir.path(), &delegate, Profile::CREATE_MODE_ASYNCHRONOUS)); |
162 | 174 |
163 // Wait for the profile to be created. | 175 // Wait for the profile to be created. |
164 observer.Wait(); | 176 observer.Wait(); |
165 CheckChromeVersion(profile.get(), true); | 177 CheckChromeVersion(profile.get(), true); |
166 } | 178 } |
167 | 179 |
168 SpinThreads(); | 180 FlushIoTaskRunnerAndSpinThreads(); |
169 } | 181 } |
170 | 182 |
171 // Test OnProfileCreate is called with is_new_profile set to false when | 183 // Test OnProfileCreate is called with is_new_profile set to false when |
172 // creating a profile asynchronously with an existing prefs file. | 184 // creating a profile asynchronously with an existing prefs file. |
173 // Flaky: http://crbug.com/141517 | 185 IN_PROC_BROWSER_TEST_F(ProfileBrowserTest, CreateOldProfileAsynchronous) { |
174 IN_PROC_BROWSER_TEST_F(ProfileBrowserTest, | |
175 DISABLED_CreateOldProfileAsynchronous) { | |
176 base::ScopedTempDir temp_dir; | 186 base::ScopedTempDir temp_dir; |
177 ASSERT_TRUE(temp_dir.CreateUniqueTempDir()); | 187 ASSERT_TRUE(temp_dir.CreateUniqueTempDir()); |
178 CreatePrefsFileInDirectory(temp_dir.path()); | 188 CreatePrefsFileInDirectory(temp_dir.path()); |
179 | 189 |
180 MockProfileDelegate delegate; | 190 MockProfileDelegate delegate; |
181 EXPECT_CALL(delegate, OnProfileCreated(testing::NotNull(), true, false)); | 191 EXPECT_CALL(delegate, OnProfileCreated(testing::NotNull(), true, false)); |
182 | 192 |
183 { | 193 { |
184 content::WindowedNotificationObserver observer( | 194 content::WindowedNotificationObserver observer( |
185 chrome::NOTIFICATION_PROFILE_CREATED, | 195 chrome::NOTIFICATION_PROFILE_CREATED, |
186 content::NotificationService::AllSources()); | 196 content::NotificationService::AllSources()); |
187 | 197 |
188 scoped_ptr<Profile> profile(CreateProfile( | 198 scoped_ptr<Profile> profile(CreateProfile( |
189 temp_dir.path(), &delegate, Profile::CREATE_MODE_ASYNCHRONOUS)); | 199 temp_dir.path(), &delegate, Profile::CREATE_MODE_ASYNCHRONOUS)); |
190 | 200 |
191 // Wait for the profile to be created. | 201 // Wait for the profile to be created. |
192 observer.Wait(); | 202 observer.Wait(); |
193 CheckChromeVersion(profile.get(), false); | 203 CheckChromeVersion(profile.get(), false); |
194 } | 204 } |
195 | 205 |
196 SpinThreads(); | 206 FlushIoTaskRunnerAndSpinThreads(); |
197 } | 207 } |
198 | 208 |
199 // Test that a README file is created for profiles that didn't have it. | 209 // Test that a README file is created for profiles that didn't have it. |
200 // Flaky: http://crbug.com/140882 | 210 IN_PROC_BROWSER_TEST_F(ProfileBrowserTest, ProfileReadmeCreated) { |
201 IN_PROC_BROWSER_TEST_F(ProfileBrowserTest, DISABLED_ProfileReadmeCreated) { | |
202 base::ScopedTempDir temp_dir; | 211 base::ScopedTempDir temp_dir; |
203 ASSERT_TRUE(temp_dir.CreateUniqueTempDir()); | 212 ASSERT_TRUE(temp_dir.CreateUniqueTempDir()); |
204 | 213 |
205 MockProfileDelegate delegate; | 214 MockProfileDelegate delegate; |
206 EXPECT_CALL(delegate, OnProfileCreated(testing::NotNull(), true, true)); | 215 EXPECT_CALL(delegate, OnProfileCreated(testing::NotNull(), true, true)); |
207 | 216 |
208 // No delay before README creation. | 217 // No delay before README creation. |
209 ProfileImpl::create_readme_delay_ms = 0; | 218 ProfileImpl::create_readme_delay_ms = 0; |
210 | 219 |
211 { | 220 { |
212 content::WindowedNotificationObserver observer( | 221 content::WindowedNotificationObserver observer( |
213 chrome::NOTIFICATION_PROFILE_CREATED, | 222 chrome::NOTIFICATION_PROFILE_CREATED, |
214 content::NotificationService::AllSources()); | 223 content::NotificationService::AllSources()); |
215 | 224 |
216 scoped_ptr<Profile> profile(CreateProfile( | 225 scoped_ptr<Profile> profile(CreateProfile( |
217 temp_dir.path(), &delegate, Profile::CREATE_MODE_ASYNCHRONOUS)); | 226 temp_dir.path(), &delegate, Profile::CREATE_MODE_ASYNCHRONOUS)); |
218 | 227 |
219 // Wait for the profile to be created. | 228 // Wait for the profile to be created. |
220 observer.Wait(); | 229 observer.Wait(); |
221 | 230 |
222 // Wait for file thread to create the README. | 231 // Wait for file thread to create the README. |
223 content::RunAllPendingInMessageLoop(content::BrowserThread::FILE); | 232 content::RunAllPendingInMessageLoop(content::BrowserThread::FILE); |
224 | 233 |
225 // Verify that README exists. | 234 // Verify that README exists. |
226 EXPECT_TRUE(base::PathExists( | 235 EXPECT_TRUE(base::PathExists( |
227 temp_dir.path().Append(chrome::kReadmeFilename))); | 236 temp_dir.path().Append(chrome::kReadmeFilename))); |
228 } | 237 } |
229 | 238 |
230 SpinThreads(); | 239 FlushIoTaskRunnerAndSpinThreads(); |
231 } | 240 } |
232 | 241 |
233 // Test that Profile can be deleted before README file is created. | 242 // Test that Profile can be deleted before README file is created. |
234 IN_PROC_BROWSER_TEST_F(ProfileBrowserTest, ProfileDeletedBeforeReadmeCreated) { | 243 IN_PROC_BROWSER_TEST_F(ProfileBrowserTest, ProfileDeletedBeforeReadmeCreated) { |
235 base::ScopedTempDir temp_dir; | 244 base::ScopedTempDir temp_dir; |
236 ASSERT_TRUE(temp_dir.CreateUniqueTempDir()); | 245 ASSERT_TRUE(temp_dir.CreateUniqueTempDir()); |
237 | 246 |
238 MockProfileDelegate delegate; | 247 MockProfileDelegate delegate; |
239 EXPECT_CALL(delegate, OnProfileCreated(testing::NotNull(), true, true)); | 248 EXPECT_CALL(delegate, OnProfileCreated(testing::NotNull(), true, true)); |
240 | 249 |
(...skipping 14 matching lines...) Expand all Loading... | |
255 temp_dir.path(), &delegate, Profile::CREATE_MODE_SYNCHRONOUS)); | 264 temp_dir.path(), &delegate, Profile::CREATE_MODE_SYNCHRONOUS)); |
256 | 265 |
257 // Delete the Profile instance before we give the file thread a chance to | 266 // Delete the Profile instance before we give the file thread a chance to |
258 // create the README. | 267 // create the README. |
259 profile.reset(); | 268 profile.reset(); |
260 | 269 |
261 // Now unblock the file thread again and run pending tasks (this includes the | 270 // Now unblock the file thread again and run pending tasks (this includes the |
262 // task for README creation). | 271 // task for README creation). |
263 unblock->Signal(); | 272 unblock->Signal(); |
264 | 273 |
265 SpinThreads(); | 274 FlushIoTaskRunnerAndSpinThreads(); |
266 } | 275 } |
267 | 276 |
268 // Test that repeated setting of exit type is handled correctly. | 277 // Test that repeated setting of exit type is handled correctly. |
269 #if defined(OS_WIN) | 278 IN_PROC_BROWSER_TEST_F(ProfileBrowserTest, ExitType) { |
270 // Flaky on Windows: http://crbug.com/163713 | |
271 #define MAYBE_ExitType DISABLED_ExitType | |
272 #else | |
273 #define MAYBE_ExitType ExitType | |
274 #endif | |
275 IN_PROC_BROWSER_TEST_F(ProfileBrowserTest, MAYBE_ExitType) { | |
276 base::ScopedTempDir temp_dir; | 279 base::ScopedTempDir temp_dir; |
277 ASSERT_TRUE(temp_dir.CreateUniqueTempDir()); | 280 ASSERT_TRUE(temp_dir.CreateUniqueTempDir()); |
278 | 281 |
279 MockProfileDelegate delegate; | 282 MockProfileDelegate delegate; |
280 EXPECT_CALL(delegate, OnProfileCreated(testing::NotNull(), true, true)); | 283 EXPECT_CALL(delegate, OnProfileCreated(testing::NotNull(), true, true)); |
281 { | 284 { |
282 scoped_ptr<Profile> profile(CreateProfile( | 285 scoped_ptr<Profile> profile(CreateProfile( |
283 temp_dir.path(), &delegate, Profile::CREATE_MODE_SYNCHRONOUS)); | 286 temp_dir.path(), &delegate, Profile::CREATE_MODE_SYNCHRONOUS)); |
284 | 287 |
285 PrefService* prefs = profile->GetPrefs(); | 288 PrefService* prefs = profile->GetPrefs(); |
286 // The initial state is crashed; store for later reference. | 289 // The initial state is crashed; store for later reference. |
287 std::string crash_value(prefs->GetString(prefs::kSessionExitType)); | 290 std::string crash_value(prefs->GetString(prefs::kSessionExitType)); |
288 | 291 |
289 // The first call to a type other than crashed should change the value. | 292 // The first call to a type other than crashed should change the value. |
290 profile->SetExitType(Profile::EXIT_SESSION_ENDED); | 293 profile->SetExitType(Profile::EXIT_SESSION_ENDED); |
291 std::string first_call_value(prefs->GetString(prefs::kSessionExitType)); | 294 std::string first_call_value(prefs->GetString(prefs::kSessionExitType)); |
292 EXPECT_NE(crash_value, first_call_value); | 295 EXPECT_NE(crash_value, first_call_value); |
293 | 296 |
294 // Subsequent calls to a non-crash value should be ignored. | 297 // Subsequent calls to a non-crash value should be ignored. |
295 profile->SetExitType(Profile::EXIT_NORMAL); | 298 profile->SetExitType(Profile::EXIT_NORMAL); |
296 std::string second_call_value(prefs->GetString(prefs::kSessionExitType)); | 299 std::string second_call_value(prefs->GetString(prefs::kSessionExitType)); |
297 EXPECT_EQ(first_call_value, second_call_value); | 300 EXPECT_EQ(first_call_value, second_call_value); |
298 | 301 |
299 // Setting back to a crashed value should work. | 302 // Setting back to a crashed value should work. |
300 profile->SetExitType(Profile::EXIT_CRASHED); | 303 profile->SetExitType(Profile::EXIT_CRASHED); |
301 std::string final_value(prefs->GetString(prefs::kSessionExitType)); | 304 std::string final_value(prefs->GetString(prefs::kSessionExitType)); |
302 EXPECT_EQ(crash_value, final_value); | 305 EXPECT_EQ(crash_value, final_value); |
303 } | 306 } |
304 | 307 |
308 FlushIoTaskRunnerAndSpinThreads(); | |
309 } | |
310 | |
311 IN_PROC_BROWSER_TEST_F(ProfileBrowserTest, WritesProfilesOnEndSession) { | |
312 base::ScopedTempDir temp_dir; | |
313 ASSERT_TRUE(temp_dir.CreateUniqueTempDir()); | |
314 | |
315 MockProfileDelegate delegate; | |
316 EXPECT_CALL(delegate, OnProfileCreated(testing::NotNull(), true, true)); | |
317 { | |
318 scoped_ptr<Profile> profile(CreateProfile( | |
319 temp_dir.path(), &delegate, Profile::CREATE_MODE_SYNCHRONOUS)); | |
320 | |
321 // This should not return until the profile data has been written to disk. | |
322 // If this test flakes, then logoff on Windows has probably broken again. | |
erikwright (departed)
2014/07/03 19:06:41
I suggest actually loading (synchronously) the con
Sigurður Ásgeirsson
2014/07/04 13:23:37
Done.
| |
323 g_browser_process->EndSession(); | |
gab
2014/07/03 18:56:56
IMO we should test that g_browser_process->EndSess
Sigurður Ásgeirsson
2014/07/04 13:23:37
I'm done with regression tests for this, if you wa
| |
324 } | |
325 | |
305 SpinThreads(); | 326 SpinThreads(); |
noms (inactive)
2014/07/03 18:07:11
Hmm, why does this call SpinThreads() where all th
Sigurður Ásgeirsson
2014/07/03 18:14:46
Because the EndSession function is required to blo
noms (inactive)
2014/07/03 18:23:42
Would you mind adding this as a comment? Thanks!
Sigurður Ásgeirsson
2014/07/03 18:28:58
Per our chat, the comment on line 321 serves the p
Sigurður Ásgeirsson
2014/07/03 18:51:09
Ugh - I misunderstood your request. Added a commen
erikwright (departed)
2014/07/03 19:06:42
Presumably, stuff still _can_ be running on the ot
Sigurður Ásgeirsson
2014/07/04 13:23:37
Done.
| |
306 } | 327 } |
OLD | NEW |