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 <stddef.h> | 7 #include <stddef.h> |
8 | 8 |
9 #include <memory> | 9 #include <memory> |
10 | 10 |
(...skipping 264 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
275 // creating a new profile synchronously. | 275 // creating a new profile synchronously. |
276 IN_PROC_BROWSER_TEST_F(ProfileBrowserTest, CreateNewProfileSynchronous) { | 276 IN_PROC_BROWSER_TEST_F(ProfileBrowserTest, CreateNewProfileSynchronous) { |
277 base::ScopedTempDir temp_dir; | 277 base::ScopedTempDir temp_dir; |
278 ASSERT_TRUE(temp_dir.CreateUniqueTempDir()); | 278 ASSERT_TRUE(temp_dir.CreateUniqueTempDir()); |
279 | 279 |
280 MockProfileDelegate delegate; | 280 MockProfileDelegate delegate; |
281 EXPECT_CALL(delegate, OnProfileCreated(testing::NotNull(), true, true)); | 281 EXPECT_CALL(delegate, OnProfileCreated(testing::NotNull(), true, true)); |
282 | 282 |
283 { | 283 { |
284 std::unique_ptr<Profile> profile(CreateProfile( | 284 std::unique_ptr<Profile> profile(CreateProfile( |
285 temp_dir.path(), &delegate, Profile::CREATE_MODE_SYNCHRONOUS)); | 285 temp_dir.GetPath(), &delegate, Profile::CREATE_MODE_SYNCHRONOUS)); |
286 CheckChromeVersion(profile.get(), true); | 286 CheckChromeVersion(profile.get(), true); |
287 } | 287 } |
288 | 288 |
289 FlushIoTaskRunnerAndSpinThreads(); | 289 FlushIoTaskRunnerAndSpinThreads(); |
290 } | 290 } |
291 | 291 |
292 // Test OnProfileCreate is called with is_new_profile set to false when | 292 // Test OnProfileCreate is called with is_new_profile set to false when |
293 // creating a profile synchronously with an existing prefs file. | 293 // creating a profile synchronously with an existing prefs file. |
294 IN_PROC_BROWSER_TEST_F(ProfileBrowserTest, CreateOldProfileSynchronous) { | 294 IN_PROC_BROWSER_TEST_F(ProfileBrowserTest, CreateOldProfileSynchronous) { |
295 base::ScopedTempDir temp_dir; | 295 base::ScopedTempDir temp_dir; |
296 ASSERT_TRUE(temp_dir.CreateUniqueTempDir()); | 296 ASSERT_TRUE(temp_dir.CreateUniqueTempDir()); |
297 CreatePrefsFileInDirectory(temp_dir.path()); | 297 CreatePrefsFileInDirectory(temp_dir.GetPath()); |
298 | 298 |
299 MockProfileDelegate delegate; | 299 MockProfileDelegate delegate; |
300 EXPECT_CALL(delegate, OnProfileCreated(testing::NotNull(), true, false)); | 300 EXPECT_CALL(delegate, OnProfileCreated(testing::NotNull(), true, false)); |
301 | 301 |
302 { | 302 { |
303 std::unique_ptr<Profile> profile(CreateProfile( | 303 std::unique_ptr<Profile> profile(CreateProfile( |
304 temp_dir.path(), &delegate, Profile::CREATE_MODE_SYNCHRONOUS)); | 304 temp_dir.GetPath(), &delegate, Profile::CREATE_MODE_SYNCHRONOUS)); |
305 CheckChromeVersion(profile.get(), false); | 305 CheckChromeVersion(profile.get(), false); |
306 } | 306 } |
307 | 307 |
308 FlushIoTaskRunnerAndSpinThreads(); | 308 FlushIoTaskRunnerAndSpinThreads(); |
309 } | 309 } |
310 | 310 |
311 // Flaky: http://crbug.com/393177 | 311 // Flaky: http://crbug.com/393177 |
312 // Test OnProfileCreate is called with is_new_profile set to true when | 312 // Test OnProfileCreate is called with is_new_profile set to true when |
313 // creating a new profile asynchronously. | 313 // creating a new profile asynchronously. |
314 IN_PROC_BROWSER_TEST_F(ProfileBrowserTest, | 314 IN_PROC_BROWSER_TEST_F(ProfileBrowserTest, |
315 DISABLED_CreateNewProfileAsynchronous) { | 315 DISABLED_CreateNewProfileAsynchronous) { |
316 base::ScopedTempDir temp_dir; | 316 base::ScopedTempDir temp_dir; |
317 ASSERT_TRUE(temp_dir.CreateUniqueTempDir()); | 317 ASSERT_TRUE(temp_dir.CreateUniqueTempDir()); |
318 | 318 |
319 MockProfileDelegate delegate; | 319 MockProfileDelegate delegate; |
320 EXPECT_CALL(delegate, OnProfileCreated(testing::NotNull(), true, true)); | 320 EXPECT_CALL(delegate, OnProfileCreated(testing::NotNull(), true, true)); |
321 | 321 |
322 { | 322 { |
323 content::WindowedNotificationObserver observer( | 323 content::WindowedNotificationObserver observer( |
324 chrome::NOTIFICATION_PROFILE_CREATED, | 324 chrome::NOTIFICATION_PROFILE_CREATED, |
325 content::NotificationService::AllSources()); | 325 content::NotificationService::AllSources()); |
326 | 326 |
327 std::unique_ptr<Profile> profile(CreateProfile( | 327 std::unique_ptr<Profile> profile(CreateProfile( |
328 temp_dir.path(), &delegate, Profile::CREATE_MODE_ASYNCHRONOUS)); | 328 temp_dir.GetPath(), &delegate, Profile::CREATE_MODE_ASYNCHRONOUS)); |
329 | 329 |
330 // Wait for the profile to be created. | 330 // Wait for the profile to be created. |
331 observer.Wait(); | 331 observer.Wait(); |
332 CheckChromeVersion(profile.get(), true); | 332 CheckChromeVersion(profile.get(), true); |
333 } | 333 } |
334 | 334 |
335 FlushIoTaskRunnerAndSpinThreads(); | 335 FlushIoTaskRunnerAndSpinThreads(); |
336 } | 336 } |
337 | 337 |
338 | 338 |
339 // Flaky: http://crbug.com/393177 | 339 // Flaky: http://crbug.com/393177 |
340 // Test OnProfileCreate is called with is_new_profile set to false when | 340 // Test OnProfileCreate is called with is_new_profile set to false when |
341 // creating a profile asynchronously with an existing prefs file. | 341 // creating a profile asynchronously with an existing prefs file. |
342 IN_PROC_BROWSER_TEST_F(ProfileBrowserTest, | 342 IN_PROC_BROWSER_TEST_F(ProfileBrowserTest, |
343 DISABLED_CreateOldProfileAsynchronous) { | 343 DISABLED_CreateOldProfileAsynchronous) { |
344 base::ScopedTempDir temp_dir; | 344 base::ScopedTempDir temp_dir; |
345 ASSERT_TRUE(temp_dir.CreateUniqueTempDir()); | 345 ASSERT_TRUE(temp_dir.CreateUniqueTempDir()); |
346 CreatePrefsFileInDirectory(temp_dir.path()); | 346 CreatePrefsFileInDirectory(temp_dir.GetPath()); |
347 | 347 |
348 MockProfileDelegate delegate; | 348 MockProfileDelegate delegate; |
349 EXPECT_CALL(delegate, OnProfileCreated(testing::NotNull(), true, false)); | 349 EXPECT_CALL(delegate, OnProfileCreated(testing::NotNull(), true, false)); |
350 | 350 |
351 { | 351 { |
352 content::WindowedNotificationObserver observer( | 352 content::WindowedNotificationObserver observer( |
353 chrome::NOTIFICATION_PROFILE_CREATED, | 353 chrome::NOTIFICATION_PROFILE_CREATED, |
354 content::NotificationService::AllSources()); | 354 content::NotificationService::AllSources()); |
355 | 355 |
356 std::unique_ptr<Profile> profile(CreateProfile( | 356 std::unique_ptr<Profile> profile(CreateProfile( |
357 temp_dir.path(), &delegate, Profile::CREATE_MODE_ASYNCHRONOUS)); | 357 temp_dir.GetPath(), &delegate, Profile::CREATE_MODE_ASYNCHRONOUS)); |
358 | 358 |
359 // Wait for the profile to be created. | 359 // Wait for the profile to be created. |
360 observer.Wait(); | 360 observer.Wait(); |
361 CheckChromeVersion(profile.get(), false); | 361 CheckChromeVersion(profile.get(), false); |
362 } | 362 } |
363 | 363 |
364 FlushIoTaskRunnerAndSpinThreads(); | 364 FlushIoTaskRunnerAndSpinThreads(); |
365 } | 365 } |
366 | 366 |
367 // Flaky: http://crbug.com/393177 | 367 // Flaky: http://crbug.com/393177 |
368 // Test that a README file is created for profiles that didn't have it. | 368 // Test that a README file is created for profiles that didn't have it. |
369 IN_PROC_BROWSER_TEST_F(ProfileBrowserTest, DISABLED_ProfileReadmeCreated) { | 369 IN_PROC_BROWSER_TEST_F(ProfileBrowserTest, DISABLED_ProfileReadmeCreated) { |
370 base::ScopedTempDir temp_dir; | 370 base::ScopedTempDir temp_dir; |
371 ASSERT_TRUE(temp_dir.CreateUniqueTempDir()); | 371 ASSERT_TRUE(temp_dir.CreateUniqueTempDir()); |
372 | 372 |
373 MockProfileDelegate delegate; | 373 MockProfileDelegate delegate; |
374 EXPECT_CALL(delegate, OnProfileCreated(testing::NotNull(), true, true)); | 374 EXPECT_CALL(delegate, OnProfileCreated(testing::NotNull(), true, true)); |
375 | 375 |
376 { | 376 { |
377 content::WindowedNotificationObserver observer( | 377 content::WindowedNotificationObserver observer( |
378 chrome::NOTIFICATION_PROFILE_CREATED, | 378 chrome::NOTIFICATION_PROFILE_CREATED, |
379 content::NotificationService::AllSources()); | 379 content::NotificationService::AllSources()); |
380 | 380 |
381 std::unique_ptr<Profile> profile(CreateProfile( | 381 std::unique_ptr<Profile> profile(CreateProfile( |
382 temp_dir.path(), &delegate, Profile::CREATE_MODE_ASYNCHRONOUS)); | 382 temp_dir.GetPath(), &delegate, Profile::CREATE_MODE_ASYNCHRONOUS)); |
383 | 383 |
384 // Wait for the profile to be created. | 384 // Wait for the profile to be created. |
385 observer.Wait(); | 385 observer.Wait(); |
386 | 386 |
387 // Verify that README exists. | 387 // Verify that README exists. |
388 EXPECT_TRUE(base::PathExists( | 388 EXPECT_TRUE( |
389 temp_dir.path().Append(chrome::kReadmeFilename))); | 389 base::PathExists(temp_dir.GetPath().Append(chrome::kReadmeFilename))); |
390 } | 390 } |
391 | 391 |
392 FlushIoTaskRunnerAndSpinThreads(); | 392 FlushIoTaskRunnerAndSpinThreads(); |
393 } | 393 } |
394 | 394 |
395 // Test that repeated setting of exit type is handled correctly. | 395 // Test that repeated setting of exit type is handled correctly. |
396 IN_PROC_BROWSER_TEST_F(ProfileBrowserTest, ExitType) { | 396 IN_PROC_BROWSER_TEST_F(ProfileBrowserTest, ExitType) { |
397 base::ScopedTempDir temp_dir; | 397 base::ScopedTempDir temp_dir; |
398 ASSERT_TRUE(temp_dir.CreateUniqueTempDir()); | 398 ASSERT_TRUE(temp_dir.CreateUniqueTempDir()); |
399 | 399 |
400 MockProfileDelegate delegate; | 400 MockProfileDelegate delegate; |
401 EXPECT_CALL(delegate, OnProfileCreated(testing::NotNull(), true, true)); | 401 EXPECT_CALL(delegate, OnProfileCreated(testing::NotNull(), true, true)); |
402 { | 402 { |
403 std::unique_ptr<Profile> profile(CreateProfile( | 403 std::unique_ptr<Profile> profile(CreateProfile( |
404 temp_dir.path(), &delegate, Profile::CREATE_MODE_SYNCHRONOUS)); | 404 temp_dir.GetPath(), &delegate, Profile::CREATE_MODE_SYNCHRONOUS)); |
405 | 405 |
406 PrefService* prefs = profile->GetPrefs(); | 406 PrefService* prefs = profile->GetPrefs(); |
407 // The initial state is crashed; store for later reference. | 407 // The initial state is crashed; store for later reference. |
408 std::string crash_value(prefs->GetString(prefs::kSessionExitType)); | 408 std::string crash_value(prefs->GetString(prefs::kSessionExitType)); |
409 | 409 |
410 // The first call to a type other than crashed should change the value. | 410 // The first call to a type other than crashed should change the value. |
411 profile->SetExitType(Profile::EXIT_SESSION_ENDED); | 411 profile->SetExitType(Profile::EXIT_SESSION_ENDED); |
412 std::string first_call_value(prefs->GetString(prefs::kSessionExitType)); | 412 std::string first_call_value(prefs->GetString(prefs::kSessionExitType)); |
413 EXPECT_NE(crash_value, first_call_value); | 413 EXPECT_NE(crash_value, first_call_value); |
414 | 414 |
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
486 | 486 |
487 IN_PROC_BROWSER_TEST_F(ProfileBrowserTest, URLRequestContextIsolation) { | 487 IN_PROC_BROWSER_TEST_F(ProfileBrowserTest, URLRequestContextIsolation) { |
488 base::ScopedTempDir temp_dir; | 488 base::ScopedTempDir temp_dir; |
489 ASSERT_TRUE(temp_dir.CreateUniqueTempDir()); | 489 ASSERT_TRUE(temp_dir.CreateUniqueTempDir()); |
490 | 490 |
491 MockProfileDelegate delegate; | 491 MockProfileDelegate delegate; |
492 EXPECT_CALL(delegate, OnProfileCreated(testing::NotNull(), true, true)); | 492 EXPECT_CALL(delegate, OnProfileCreated(testing::NotNull(), true, true)); |
493 | 493 |
494 { | 494 { |
495 std::unique_ptr<Profile> profile(CreateProfile( | 495 std::unique_ptr<Profile> profile(CreateProfile( |
496 temp_dir.path(), &delegate, Profile::CREATE_MODE_SYNCHRONOUS)); | 496 temp_dir.GetPath(), &delegate, Profile::CREATE_MODE_SYNCHRONOUS)); |
497 | 497 |
498 scoped_refptr<const extensions::Extension> app = | 498 scoped_refptr<const extensions::Extension> app = |
499 BuildTestApp(profile.get()); | 499 BuildTestApp(profile.get()); |
500 content::StoragePartition* extension_partition = | 500 content::StoragePartition* extension_partition = |
501 content::BrowserContext::GetStoragePartitionForSite( | 501 content::BrowserContext::GetStoragePartitionForSite( |
502 profile.get(), | 502 profile.get(), |
503 extensions::Extension::GetBaseURLFromExtensionId(app->id())); | 503 extensions::Extension::GetBaseURLFromExtensionId(app->id())); |
504 net::URLRequestContextGetter* extension_context_getter = | 504 net::URLRequestContextGetter* extension_context_getter = |
505 extension_partition->GetURLRequestContext(); | 505 extension_partition->GetURLRequestContext(); |
506 net::URLRequestContextGetter* main_context_getter = | 506 net::URLRequestContextGetter* main_context_getter = |
(...skipping 14 matching lines...) Expand all Loading... |
521 IN_PROC_BROWSER_TEST_F(ProfileBrowserTest, | 521 IN_PROC_BROWSER_TEST_F(ProfileBrowserTest, |
522 OffTheRecordURLRequestContextIsolation) { | 522 OffTheRecordURLRequestContextIsolation) { |
523 base::ScopedTempDir temp_dir; | 523 base::ScopedTempDir temp_dir; |
524 ASSERT_TRUE(temp_dir.CreateUniqueTempDir()); | 524 ASSERT_TRUE(temp_dir.CreateUniqueTempDir()); |
525 | 525 |
526 MockProfileDelegate delegate; | 526 MockProfileDelegate delegate; |
527 EXPECT_CALL(delegate, OnProfileCreated(testing::NotNull(), true, true)); | 527 EXPECT_CALL(delegate, OnProfileCreated(testing::NotNull(), true, true)); |
528 | 528 |
529 { | 529 { |
530 std::unique_ptr<Profile> profile(CreateProfile( | 530 std::unique_ptr<Profile> profile(CreateProfile( |
531 temp_dir.path(), &delegate, Profile::CREATE_MODE_SYNCHRONOUS)); | 531 temp_dir.GetPath(), &delegate, Profile::CREATE_MODE_SYNCHRONOUS)); |
532 Profile* otr_profile = profile->GetOffTheRecordProfile(); | 532 Profile* otr_profile = profile->GetOffTheRecordProfile(); |
533 | 533 |
534 scoped_refptr<const extensions::Extension> app = BuildTestApp(otr_profile); | 534 scoped_refptr<const extensions::Extension> app = BuildTestApp(otr_profile); |
535 content::StoragePartition* extension_partition = | 535 content::StoragePartition* extension_partition = |
536 content::BrowserContext::GetStoragePartitionForSite( | 536 content::BrowserContext::GetStoragePartitionForSite( |
537 otr_profile, | 537 otr_profile, |
538 extensions::Extension::GetBaseURLFromExtensionId(app->id())); | 538 extensions::Extension::GetBaseURLFromExtensionId(app->id())); |
539 net::URLRequestContextGetter* extension_context_getter = | 539 net::URLRequestContextGetter* extension_context_getter = |
540 extension_partition->GetURLRequestContext(); | 540 extension_partition->GetURLRequestContext(); |
541 net::URLRequestContextGetter* main_context_getter = | 541 net::URLRequestContextGetter* main_context_getter = |
(...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
689 } | 689 } |
690 | 690 |
691 // Verifies the cache directory supports multiple profiles when it's overriden | 691 // Verifies the cache directory supports multiple profiles when it's overriden |
692 // by group policy or command line switches. | 692 // by group policy or command line switches. |
693 IN_PROC_BROWSER_TEST_F(ProfileBrowserTest, DiskCacheDirOverride) { | 693 IN_PROC_BROWSER_TEST_F(ProfileBrowserTest, DiskCacheDirOverride) { |
694 int size; | 694 int size; |
695 const base::FilePath::StringPieceType profile_name = | 695 const base::FilePath::StringPieceType profile_name = |
696 FILE_PATH_LITERAL("Profile 1"); | 696 FILE_PATH_LITERAL("Profile 1"); |
697 base::ScopedTempDir mock_user_data_dir; | 697 base::ScopedTempDir mock_user_data_dir; |
698 ASSERT_TRUE(mock_user_data_dir.CreateUniqueTempDir()); | 698 ASSERT_TRUE(mock_user_data_dir.CreateUniqueTempDir()); |
699 base::FilePath profile_path = mock_user_data_dir.path().Append(profile_name); | 699 base::FilePath profile_path = |
| 700 mock_user_data_dir.GetPath().Append(profile_name); |
700 ProfileImpl* profile_impl = static_cast<ProfileImpl*>(browser()->profile()); | 701 ProfileImpl* profile_impl = static_cast<ProfileImpl*>(browser()->profile()); |
701 | 702 |
702 { | 703 { |
703 profile_impl->GetPrefs()->SetFilePath(prefs::kDiskCacheDir, | 704 profile_impl->GetPrefs()->SetFilePath(prefs::kDiskCacheDir, |
704 base::FilePath()); | 705 base::FilePath()); |
705 | 706 |
706 base::FilePath cache_path = profile_path; | 707 base::FilePath cache_path = profile_path; |
707 profile_impl->GetCacheParameters(false, &cache_path, &size); | 708 profile_impl->GetCacheParameters(false, &cache_path, &size); |
708 EXPECT_EQ(profile_path, cache_path); | 709 EXPECT_EQ(profile_path, cache_path); |
709 } | 710 } |
710 | 711 |
711 { | 712 { |
712 base::ScopedTempDir temp_disk_cache_dir; | 713 base::ScopedTempDir temp_disk_cache_dir; |
713 ASSERT_TRUE(temp_disk_cache_dir.CreateUniqueTempDir()); | 714 ASSERT_TRUE(temp_disk_cache_dir.CreateUniqueTempDir()); |
714 profile_impl->GetPrefs()->SetFilePath(prefs::kDiskCacheDir, | 715 profile_impl->GetPrefs()->SetFilePath(prefs::kDiskCacheDir, |
715 temp_disk_cache_dir.path()); | 716 temp_disk_cache_dir.GetPath()); |
716 | 717 |
717 base::FilePath cache_path = profile_path; | 718 base::FilePath cache_path = profile_path; |
718 profile_impl->GetCacheParameters(false, &cache_path, &size); | 719 profile_impl->GetCacheParameters(false, &cache_path, &size); |
719 EXPECT_EQ(temp_disk_cache_dir.path().Append(profile_name), cache_path); | 720 EXPECT_EQ(temp_disk_cache_dir.GetPath().Append(profile_name), cache_path); |
720 } | 721 } |
721 } | 722 } |
OLD | NEW |