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

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

Issue 294033002: Multi-profile flag cleanup. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Return --test-type flag back to profile_manager_unittest.cc Created 6 years, 7 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 360 matching lines...) Expand 10 before | Expand all | Expand 10 after
371 virtual Profile* CreateProfileHelper( 371 virtual Profile* CreateProfileHelper(
372 const base::FilePath& file_path) OVERRIDE { 372 const base::FilePath& file_path) OVERRIDE {
373 TestingProfile::Builder builder; 373 TestingProfile::Builder builder;
374 builder.SetGuestSession(); 374 builder.SetGuestSession();
375 builder.SetPath(file_path); 375 builder.SetPath(file_path);
376 TestingProfile* testing_profile = builder.Build().release(); 376 TestingProfile* testing_profile = builder.Build().release();
377 return testing_profile; 377 return testing_profile;
378 } 378 }
379 }; 379 };
380 380
381 class ProfileManagerGuestTest : public ProfileManagerTest, 381 class ProfileManagerGuestTest : public ProfileManagerTest {
382 public testing::WithParamInterface<bool> {
383 protected: 382 protected:
384 virtual void SetUp() { 383 virtual void SetUp() {
385 // Create a new temporary directory, and store the path 384 // Create a new temporary directory, and store the path
386 ASSERT_TRUE(temp_dir_.CreateUniqueTempDir()); 385 ASSERT_TRUE(temp_dir_.CreateUniqueTempDir());
387 TestingBrowserProcess::GetGlobal()->SetProfileManager( 386 TestingBrowserProcess::GetGlobal()->SetProfileManager(
388 new UnittestGuestProfileManager(temp_dir_.path())); 387 new UnittestGuestProfileManager(temp_dir_.path()));
389 388
390 #if defined(OS_CHROMEOS) 389 #if defined(OS_CHROMEOS)
391 CommandLine* cl = CommandLine::ForCurrentProcess(); 390 CommandLine* cl = CommandLine::ForCurrentProcess();
392 if (GetParam()) 391 // This switch is needed to skip non-test specific behavior in
393 cl->AppendSwitch(switches::kMultiProfiles); 392 // ProfileManager (accessing DBusThreadManager).
393 cl->AppendSwitch(switches::kTestType);
394 394
395 cl->AppendSwitch(switches::kTestType); 395 cl->AppendSwitchASCII(chromeos::switches::kLoginProfile,
396 if (profiles::IsMultipleProfilesEnabled()) { 396 std::string(chrome::kProfileDirPrefix) +
397 cl->AppendSwitchASCII(chromeos::switches::kLoginProfile, 397 chromeos::UserManager::kGuestUserName);
398 std::string(chrome::kProfileDirPrefix) +
399 chromeos::UserManager::kGuestUserName);
400 } else {
401 cl->AppendSwitchASCII(chromeos::switches::kLoginProfile, "user");
402 }
403 cl->AppendSwitch(chromeos::switches::kGuestSession); 398 cl->AppendSwitch(chromeos::switches::kGuestSession);
404 cl->AppendSwitch(::switches::kIncognito); 399 cl->AppendSwitch(::switches::kIncognito);
405 400
406 chromeos::UserManager::Get()->UserLoggedIn( 401 chromeos::UserManager::Get()->UserLoggedIn(
407 chromeos::UserManager::kGuestUserName, 402 chromeos::UserManager::kGuestUserName,
408 chromeos::UserManager::kGuestUserName, 403 chromeos::UserManager::kGuestUserName,
409 false); 404 false);
410 #endif 405 #endif
411 } 406 }
412 }; 407 };
413 408
414 INSTANTIATE_TEST_CASE_P(ProfileManagerGuestTestInstantiation, 409 TEST_F(ProfileManagerGuestTest, GetLastUsedProfileAllowedByPolicy) {
415 ProfileManagerGuestTest,
416 testing::Bool());
417
418 TEST_P(ProfileManagerGuestTest, GetLastUsedProfileAllowedByPolicy) {
419 ProfileManager* profile_manager = g_browser_process->profile_manager(); 410 ProfileManager* profile_manager = g_browser_process->profile_manager();
420 ASSERT_TRUE(profile_manager); 411 ASSERT_TRUE(profile_manager);
421 412
422 Profile* profile = profile_manager->GetLastUsedProfileAllowedByPolicy(); 413 Profile* profile = profile_manager->GetLastUsedProfileAllowedByPolicy();
423 ASSERT_TRUE(profile); 414 ASSERT_TRUE(profile);
424 EXPECT_TRUE(profile->IsOffTheRecord()); 415 EXPECT_TRUE(profile->IsOffTheRecord());
425 } 416 }
426 417
427 #if defined(OS_CHROMEOS) 418 #if defined(OS_CHROMEOS)
428 TEST_P(ProfileManagerGuestTest, GuestProfileIngonito) { 419 TEST_F(ProfileManagerGuestTest, GuestProfileIngonito) {
429 Profile* primary_profile = ProfileManager::GetPrimaryUserProfile(); 420 Profile* primary_profile = ProfileManager::GetPrimaryUserProfile();
430 EXPECT_TRUE(primary_profile->IsOffTheRecord()); 421 EXPECT_TRUE(primary_profile->IsOffTheRecord());
431 422
432 Profile* active_profile = ProfileManager::GetActiveUserProfile(); 423 Profile* active_profile = ProfileManager::GetActiveUserProfile();
433 EXPECT_TRUE(active_profile->IsOffTheRecord()); 424 EXPECT_TRUE(active_profile->IsOffTheRecord());
434 425
435 EXPECT_TRUE(active_profile->IsSameProfile(primary_profile)); 426 EXPECT_TRUE(active_profile->IsSameProfile(primary_profile));
436 427
437 Profile* last_used_profile = ProfileManager::GetLastUsedProfile(); 428 Profile* last_used_profile = ProfileManager::GetLastUsedProfile();
438 EXPECT_TRUE(last_used_profile->IsOffTheRecord()); 429 EXPECT_TRUE(last_used_profile->IsOffTheRecord());
(...skipping 668 matching lines...) Expand 10 before | Expand all | Expand 10 after
1107 dest_path2.BaseName().MaybeAsASCII()); 1098 dest_path2.BaseName().MaybeAsASCII());
1108 profile_manager->ScheduleProfileForDeletion(dest_path2, 1099 profile_manager->ScheduleProfileForDeletion(dest_path2,
1109 ProfileManager::CreateCallback()); 1100 ProfileManager::CreateCallback());
1110 // Spin the message loop so that all the callbacks can finish running. 1101 // Spin the message loop so that all the callbacks can finish running.
1111 base::RunLoop().RunUntilIdle(); 1102 base::RunLoop().RunUntilIdle();
1112 1103
1113 EXPECT_EQ(dest_path3, profile_manager->GetLastUsedProfile()->GetPath()); 1104 EXPECT_EQ(dest_path3, profile_manager->GetLastUsedProfile()->GetPath());
1114 EXPECT_EQ(profile_name3, local_state->GetString(prefs::kProfileLastUsed)); 1105 EXPECT_EQ(profile_name3, local_state->GetString(prefs::kProfileLastUsed));
1115 } 1106 }
1116 #endif // !defined(OS_MACOSX) 1107 #endif // !defined(OS_MACOSX)
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698