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

Side by Side Diff: chrome/browser/profiles/profile_manager_unittest.cc

Issue 181403006: Make TestingProfile auto-create incognito profiles. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: remove broken and no-longer-applicable test Created 6 years, 9 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
OLDNEW
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 <string> 5 #include <string>
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/path_service.h" 10 #include "base/path_service.h"
(...skipping 355 matching lines...) Expand 10 before | Expand all | Expand 10 after
366 explicit UnittestGuestProfileManager(const base::FilePath& user_data_dir) 366 explicit UnittestGuestProfileManager(const base::FilePath& user_data_dir)
367 : UnittestProfileManager(user_data_dir) {} 367 : UnittestProfileManager(user_data_dir) {}
368 368
369 protected: 369 protected:
370 virtual Profile* CreateProfileHelper( 370 virtual Profile* CreateProfileHelper(
371 const base::FilePath& file_path) OVERRIDE { 371 const base::FilePath& file_path) OVERRIDE {
372 TestingProfile::Builder builder; 372 TestingProfile::Builder builder;
373 builder.SetGuestSession(); 373 builder.SetGuestSession();
374 builder.SetPath(file_path); 374 builder.SetPath(file_path);
375 TestingProfile* testing_profile = builder.Build().release(); 375 TestingProfile* testing_profile = builder.Build().release();
376
377 TestingProfile::Builder incognito_builder;
378 incognito_builder.SetIncognito();
379 incognito_builder.SetGuestSession();
380 incognito_builder.SetPath(ProfileManager::GetGuestProfilePath());
381 testing_profile->SetOffTheRecordProfile(
382 incognito_builder.Build().PassAs<Profile>());
383
384 return testing_profile; 376 return testing_profile;
385 } 377 }
386 }; 378 };
387 379
388 class ProfileManagerGuestTest : public ProfileManagerTest { 380 class ProfileManagerGuestTest : public ProfileManagerTest {
389 protected: 381 protected:
390 virtual void SetUp() { 382 virtual void SetUp() {
391 // Create a new temporary directory, and store the path 383 // Create a new temporary directory, and store the path
392 ASSERT_TRUE(temp_dir_.CreateUniqueTempDir()); 384 ASSERT_TRUE(temp_dir_.CreateUniqueTempDir());
393 TestingBrowserProcess::GetGlobal()->SetProfileManager( 385 TestingBrowserProcess::GetGlobal()->SetProfileManager(
(...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after
531 ProfileManager* profile_manager = g_browser_process->profile_manager(); 523 ProfileManager* profile_manager = g_browser_process->profile_manager();
532 ASSERT_TRUE(profile_manager); 524 ASSERT_TRUE(profile_manager);
533 525
534 Profile* profile = profile_manager->GetLastUsedProfileAllowedByPolicy(); 526 Profile* profile = profile_manager->GetLastUsedProfileAllowedByPolicy();
535 ASSERT_TRUE(profile); 527 ASSERT_TRUE(profile);
536 EXPECT_FALSE(profile->IsOffTheRecord()); 528 EXPECT_FALSE(profile->IsOffTheRecord());
537 PrefService* prefs = profile->GetPrefs(); 529 PrefService* prefs = profile->GetPrefs();
538 EXPECT_EQ(IncognitoModePrefs::ENABLED, 530 EXPECT_EQ(IncognitoModePrefs::ENABLED,
539 IncognitoModePrefs::GetAvailability(prefs)); 531 IncognitoModePrefs::GetAvailability(prefs));
540 532
541 // Attach an incognito Profile to the TestingProfile.
542 ASSERT_FALSE(profile->GetOffTheRecordProfile());
543 TestingProfile::Builder builder;
544 builder.SetIncognito();
545 scoped_ptr<TestingProfile> incognito_profile = builder.Build();
546 EXPECT_TRUE(incognito_profile->IsOffTheRecord());
547 TestingProfile* testing_profile = static_cast<TestingProfile*>(profile);
548 testing_profile->SetOffTheRecordProfile(incognito_profile.PassAs<Profile>());
549 ASSERT_TRUE(profile->GetOffTheRecordProfile()); 533 ASSERT_TRUE(profile->GetOffTheRecordProfile());
550 534
551 IncognitoModePrefs::SetAvailability(prefs, IncognitoModePrefs::DISABLED); 535 IncognitoModePrefs::SetAvailability(prefs, IncognitoModePrefs::DISABLED);
552 EXPECT_FALSE( 536 EXPECT_FALSE(
553 profile_manager->GetLastUsedProfileAllowedByPolicy()->IsOffTheRecord()); 537 profile_manager->GetLastUsedProfileAllowedByPolicy()->IsOffTheRecord());
554 538
555 // GetLastUsedProfileAllowedByPolicy() returns the incognito Profile when 539 // GetLastUsedProfileAllowedByPolicy() returns the incognito Profile when
556 // incognito mode is forced. 540 // incognito mode is forced.
557 IncognitoModePrefs::SetAvailability(prefs, IncognitoModePrefs::FORCED); 541 IncognitoModePrefs::SetAvailability(prefs, IncognitoModePrefs::FORCED);
558 EXPECT_TRUE( 542 EXPECT_TRUE(
(...skipping 537 matching lines...) Expand 10 before | Expand all | Expand 10 after
1096 dest_path2.BaseName().MaybeAsASCII()); 1080 dest_path2.BaseName().MaybeAsASCII());
1097 profile_manager->ScheduleProfileForDeletion(dest_path2, 1081 profile_manager->ScheduleProfileForDeletion(dest_path2,
1098 ProfileManager::CreateCallback()); 1082 ProfileManager::CreateCallback());
1099 // Spin the message loop so that all the callbacks can finish running. 1083 // Spin the message loop so that all the callbacks can finish running.
1100 base::RunLoop().RunUntilIdle(); 1084 base::RunLoop().RunUntilIdle();
1101 1085
1102 EXPECT_EQ(dest_path3, profile_manager->GetLastUsedProfile()->GetPath()); 1086 EXPECT_EQ(dest_path3, profile_manager->GetLastUsedProfile()->GetPath());
1103 EXPECT_EQ(profile_name3, local_state->GetString(prefs::kProfileLastUsed)); 1087 EXPECT_EQ(profile_name3, local_state->GetString(prefs::kProfileLastUsed));
1104 } 1088 }
1105 #endif // !defined(OS_MACOSX) 1089 #endif // !defined(OS_MACOSX)
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698