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/platform_file.h" | 8 #include "base/platform_file.h" |
9 #include "base/scoped_temp_dir.h" | 9 #include "base/scoped_temp_dir.h" |
10 #include "base/version.h" | 10 #include "base/version.h" |
(...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
141 scoped_ptr<Profile> profile(Profile::CreateProfile( | 141 scoped_ptr<Profile> profile(Profile::CreateProfile( |
142 temp_dir.path(), &delegate, Profile::CREATE_MODE_ASYNCHRONOUS)); | 142 temp_dir.path(), &delegate, Profile::CREATE_MODE_ASYNCHRONOUS)); |
143 ASSERT_TRUE(profile.get()); | 143 ASSERT_TRUE(profile.get()); |
144 | 144 |
145 // Wait for the profile to be created. | 145 // Wait for the profile to be created. |
146 content::WindowedNotificationObserver observer( | 146 content::WindowedNotificationObserver observer( |
147 chrome::NOTIFICATION_PROFILE_CREATED, | 147 chrome::NOTIFICATION_PROFILE_CREATED, |
148 content::Source<Profile>(profile.get())); | 148 content::Source<Profile>(profile.get())); |
149 observer.Wait(); | 149 observer.Wait(); |
150 | 150 |
151 ui_test_utils::RunAllPendingInMessageLoop(content::BrowserThread::FILE); | 151 content::RunAllPendingInMessageLoop(content::BrowserThread::FILE); |
152 | 152 |
153 // Verify that README exists. | 153 // Verify that README exists. |
154 EXPECT_TRUE(file_util::PathExists( | 154 EXPECT_TRUE(file_util::PathExists( |
155 temp_dir.path().Append(chrome::kReadmeFilename))); | 155 temp_dir.path().Append(chrome::kReadmeFilename))); |
156 } | 156 } |
157 | 157 |
158 // Test that Profile can be deleted before README file is created. | 158 // Test that Profile can be deleted before README file is created. |
159 IN_PROC_BROWSER_TEST_F(ProfileBrowserTest, ProfileDeletedBeforeReadmeCreated) { | 159 IN_PROC_BROWSER_TEST_F(ProfileBrowserTest, ProfileDeletedBeforeReadmeCreated) { |
160 ScopedTempDir temp_dir; | 160 ScopedTempDir temp_dir; |
161 ASSERT_TRUE(temp_dir.CreateUniqueTempDir()); | 161 ASSERT_TRUE(temp_dir.CreateUniqueTempDir()); |
162 | 162 |
163 MockProfileDelegate delegate; | 163 MockProfileDelegate delegate; |
164 EXPECT_CALL(delegate, OnProfileCreated(testing::NotNull(), true, true)); | 164 EXPECT_CALL(delegate, OnProfileCreated(testing::NotNull(), true, true)); |
165 | 165 |
166 // No delay before README creation. | 166 // No delay before README creation. |
167 ProfileImpl::create_readme_delay_ms = 0; | 167 ProfileImpl::create_readme_delay_ms = 0; |
168 | 168 |
169 scoped_ptr<Profile> profile(Profile::CreateProfile( | 169 scoped_ptr<Profile> profile(Profile::CreateProfile( |
170 temp_dir.path(), &delegate, Profile::CREATE_MODE_SYNCHRONOUS)); | 170 temp_dir.path(), &delegate, Profile::CREATE_MODE_SYNCHRONOUS)); |
171 ASSERT_TRUE(profile.get()); | 171 ASSERT_TRUE(profile.get()); |
172 | 172 |
173 // Delete the Profile instance and run pending tasks (this includes the task | 173 // Delete the Profile instance and run pending tasks (this includes the task |
174 // for README creation). | 174 // for README creation). |
175 profile.reset(); | 175 profile.reset(); |
176 ui_test_utils::RunAllPendingInMessageLoop(); | 176 content::RunAllPendingInMessageLoop(); |
177 ui_test_utils::RunAllPendingInMessageLoop(content::BrowserThread::FILE); | 177 content::RunAllPendingInMessageLoop(content::BrowserThread::FILE); |
178 } | 178 } |
OLD | NEW |