Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1234)

Side by Side Diff: chrome/browser/sync/test/integration/sync_test.cc

Issue 7780031: Fix sync test crashing when multiprofiles are enabled on Mac. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' Created 9 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « chrome/browser/sync/test/integration/sync_test.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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/sync/test/integration/sync_test.h" 5 #include "chrome/browser/sync/test/integration/sync_test.h"
6 6
7 #include <vector> 7 #include <vector>
8 8
9 #include "base/basictypes.h" 9 #include "base/basictypes.h"
10 #include "base/command_line.h" 10 #include "base/command_line.h"
(...skipping 213 matching lines...) Expand 10 before | Expand all | Expand 10 after
224 224
225 // static 225 // static
226 Profile* SyncTest::MakeProfile(const FilePath::StringType name) { 226 Profile* SyncTest::MakeProfile(const FilePath::StringType name) {
227 FilePath path; 227 FilePath path;
228 PathService::Get(chrome::DIR_USER_DATA, &path); 228 PathService::Get(chrome::DIR_USER_DATA, &path);
229 path = path.Append(name); 229 path = path.Append(name);
230 230
231 if (!file_util::PathExists(path)) 231 if (!file_util::PathExists(path))
232 CHECK(file_util::CreateDirectory(path)); 232 CHECK(file_util::CreateDirectory(path));
233 233
234 return Profile::CreateProfile(path); 234 Profile* profile = Profile::CreateProfile(path);
235 g_browser_process->profile_manager()->RegisterTestingProfile(profile, true);
236 return profile;
235 } 237 }
236 238
237 Profile* SyncTest::GetProfile(int index) { 239 Profile* SyncTest::GetProfile(int index) {
238 if (profiles_.empty()) 240 if (profiles_.empty())
239 LOG(FATAL) << "SetupClients() has not yet been called."; 241 LOG(FATAL) << "SetupClients() has not yet been called.";
240 if (index < 0 || index >= static_cast<int>(profiles_.size())) 242 if (index < 0 || index >= static_cast<int>(profiles_.size()))
241 LOG(FATAL) << "GetProfile(): Index is out of bounds."; 243 LOG(FATAL) << "GetProfile(): Index is out of bounds.";
242 return profiles_[index]; 244 return profiles_[index];
243 } 245 }
244 246
245 Browser* SyncTest::GetBrowser(int index) { 247 Browser* SyncTest::GetBrowser(int index) {
246 if (browsers_.empty()) 248 if (browsers_.empty())
247 LOG(FATAL) << "SetupClients() has not yet been called."; 249 LOG(FATAL) << "SetupClients() has not yet been called.";
248 if (index < 0 || index >= static_cast<int>(browsers_.size())) 250 if (index < 0 || index >= static_cast<int>(browsers_.size()))
249 LOG(FATAL) << "GetBrowser(): Index is out of bounds."; 251 LOG(FATAL) << "GetBrowser(): Index is out of bounds.";
250 return browsers_[index]; 252 return browsers_[index];
251 } 253 }
252 254
253 ProfileSyncServiceHarness* SyncTest::GetClient(int index) { 255 ProfileSyncServiceHarness* SyncTest::GetClient(int index) {
254 if (clients_.empty()) 256 if (clients_.empty())
255 LOG(FATAL) << "SetupClients() has not yet been called."; 257 LOG(FATAL) << "SetupClients() has not yet been called.";
256 if (index < 0 || index >= static_cast<int>(clients_.size())) 258 if (index < 0 || index >= static_cast<int>(clients_.size()))
257 LOG(FATAL) << "GetClient(): Index is out of bounds."; 259 LOG(FATAL) << "GetClient(): Index is out of bounds.";
258 return clients_[index]; 260 return clients_[index];
259 } 261 }
260 262
261 Profile* SyncTest::verifier() { 263 Profile* SyncTest::verifier() {
262 if (verifier_.get() == NULL) 264 if (verifier_ == NULL)
263 LOG(FATAL) << "SetupClients() has not yet been called."; 265 LOG(FATAL) << "SetupClients() has not yet been called.";
264 return verifier_.get(); 266 return verifier_;
265 } 267 }
266 268
267 void SyncTest::DisableVerifier() { 269 void SyncTest::DisableVerifier() {
268 use_verifier_ = false; 270 use_verifier_ = false;
269 } 271 }
270 272
271 bool SyncTest::SetupClients() { 273 bool SyncTest::SetupClients() {
272 if (num_clients_ <= 0) 274 if (num_clients_ <= 0)
273 LOG(FATAL) << "num_clients_ incorrectly initialized."; 275 LOG(FATAL) << "num_clients_ incorrectly initialized.";
274 if (!profiles_.empty() || !browsers_.empty() || !clients_.empty()) 276 if (!profiles_.empty() || !browsers_.empty() || !clients_.empty())
(...skipping 13 matching lines...) Expand all
288 290
289 clients_.push_back( 291 clients_.push_back(
290 new ProfileSyncServiceHarness(GetProfile(i), username_, password_)); 292 new ProfileSyncServiceHarness(GetProfile(i), username_, password_));
291 EXPECT_FALSE(GetClient(i) == NULL) << "GetClient(" << i << ") failed."; 293 EXPECT_FALSE(GetClient(i) == NULL) << "GetClient(" << i << ") failed.";
292 294
293 ui_test_utils::WaitForBookmarkModelToLoad( 295 ui_test_utils::WaitForBookmarkModelToLoad(
294 GetProfile(i)->GetBookmarkModel()); 296 GetProfile(i)->GetBookmarkModel());
295 } 297 }
296 298
297 // Create the verifier profile. 299 // Create the verifier profile.
298 verifier_.reset(MakeProfile(FILE_PATH_LITERAL("Verifier"))); 300 verifier_ = MakeProfile(FILE_PATH_LITERAL("Verifier"));
299 ui_test_utils::WaitForBookmarkModelToLoad(verifier()->GetBookmarkModel()); 301 ui_test_utils::WaitForBookmarkModelToLoad(verifier()->GetBookmarkModel());
300 return (verifier_.get() != NULL); 302 return (verifier_ != NULL);
301 } 303 }
302 304
303 bool SyncTest::SetupSync() { 305 bool SyncTest::SetupSync() {
304 // Create sync profiles and clients if they haven't already been created. 306 // Create sync profiles and clients if they haven't already been created.
305 if (profiles_.empty()) { 307 if (profiles_.empty()) {
306 if (!SetupClients()) 308 if (!SetupClients())
307 LOG(FATAL) << "SetupClients() failed."; 309 LOG(FATAL) << "SetupClients() failed.";
308 } 310 }
309 311
310 // Sync each of the profiles. 312 // Sync each of the profiles.
311 for (int i = 0; i < num_clients_; ++i) { 313 for (int i = 0; i < num_clients_; ++i) {
312 if (!GetClient(i)->SetupSync()) 314 if (!GetClient(i)->SetupSync())
313 LOG(FATAL) << "SetupSync() failed."; 315 LOG(FATAL) << "SetupSync() failed.";
314 } 316 }
315 317
316 return true; 318 return true;
317 } 319 }
318 320
319 void SyncTest::CleanUpOnMainThread() { 321 void SyncTest::CleanUpOnMainThread() {
320 // Close all browser windows. 322 // Close all browser windows.
321 BrowserList::CloseAllBrowsers(); 323 BrowserList::CloseAllBrowsers();
322 ui_test_utils::RunAllPendingInMessageLoop(); 324 ui_test_utils::RunAllPendingInMessageLoop();
323 325
324 // All browsers should be closed at this point, or else we could see memory 326 // All browsers should be closed at this point, or else we could see memory
325 // corruption in QuitBrowser(). 327 // corruption in QuitBrowser().
326 CHECK_EQ(0U, BrowserList::size()); 328 CHECK_EQ(0U, BrowserList::size());
327
328 profiles_.reset();
329 clients_.reset(); 329 clients_.reset();
330 verifier_.reset(NULL);
331 } 330 }
332 331
333 void SyncTest::SetUpInProcessBrowserTestFixture() { 332 void SyncTest::SetUpInProcessBrowserTestFixture() {
334 // We don't take a reference to |resolver|, but mock_host_resolver_override_ 333 // We don't take a reference to |resolver|, but mock_host_resolver_override_
335 // does, so effectively assumes ownership. 334 // does, so effectively assumes ownership.
336 net::RuleBasedHostResolverProc* resolver = 335 net::RuleBasedHostResolverProc* resolver =
337 new net::RuleBasedHostResolverProc(host_resolver()); 336 new net::RuleBasedHostResolverProc(host_resolver());
338 resolver->AllowDirectLookup("*.google.com"); 337 resolver->AllowDirectLookup("*.google.com");
339 // On Linux, we use Chromium's NSS implementation which uses the following 338 // On Linux, we use Chromium's NSS implementation which uses the following
340 // hosts for certificate verification. Without these overrides, running the 339 // hosts for certificate verification. Without these overrides, running the
(...skipping 282 matching lines...) Expand 10 before | Expand all | Expand 10 after
623 const net::ProxyConfig& proxy_config) { 622 const net::ProxyConfig& proxy_config) {
624 base::WaitableEvent done(false, false); 623 base::WaitableEvent done(false, false);
625 BrowserThread::PostTask( 624 BrowserThread::PostTask(
626 BrowserThread::IO, 625 BrowserThread::IO,
627 FROM_HERE, 626 FROM_HERE,
628 new SetProxyConfigTask(&done, 627 new SetProxyConfigTask(&done,
629 context_getter, 628 context_getter,
630 proxy_config)); 629 proxy_config));
631 done.Wait(); 630 done.Wait();
632 } 631 }
OLDNEW
« no previous file with comments | « chrome/browser/sync/test/integration/sync_test.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698