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

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

Issue 323133005: Enable consistent identity on android platform by default. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebased Created 6 years, 6 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 17 matching lines...) Expand all
28 #include "chrome/browser/profiles/profiles_state.h" 28 #include "chrome/browser/profiles/profiles_state.h"
29 #include "chrome/browser/ui/browser.h" 29 #include "chrome/browser/ui/browser.h"
30 #include "chrome/common/chrome_constants.h" 30 #include "chrome/common/chrome_constants.h"
31 #include "chrome/common/chrome_paths.h" 31 #include "chrome/common/chrome_paths.h"
32 #include "chrome/common/chrome_switches.h" 32 #include "chrome/common/chrome_switches.h"
33 #include "chrome/common/pref_names.h" 33 #include "chrome/common/pref_names.h"
34 #include "chrome/test/base/scoped_testing_local_state.h" 34 #include "chrome/test/base/scoped_testing_local_state.h"
35 #include "chrome/test/base/test_browser_window.h" 35 #include "chrome/test/base/test_browser_window.h"
36 #include "chrome/test/base/testing_browser_process.h" 36 #include "chrome/test/base/testing_browser_process.h"
37 #include "chrome/test/base/testing_profile.h" 37 #include "chrome/test/base/testing_profile.h"
38 #include "components/signin/core/common/profile_management_switches.h"
38 #include "content/public/browser/notification_service.h" 39 #include "content/public/browser/notification_service.h"
39 #include "content/public/common/content_switches.h" 40 #include "content/public/common/content_switches.h"
40 #include "content/public/test/test_browser_thread_bundle.h" 41 #include "content/public/test/test_browser_thread_bundle.h"
41 #include "grit/generated_resources.h" 42 #include "grit/generated_resources.h"
42 #include "testing/gmock/include/gmock/gmock.h" 43 #include "testing/gmock/include/gmock/gmock.h"
43 #include "testing/gtest/include/gtest/gtest.h" 44 #include "testing/gtest/include/gtest/gtest.h"
44 #include "ui/base/l10n/l10n_util.h" 45 #include "ui/base/l10n/l10n_util.h"
45 46
46 #if defined(OS_CHROMEOS) 47 #if defined(OS_CHROMEOS)
47 #include "chrome/browser/chromeos/login/users/mock_user_manager.h" 48 #include "chrome/browser/chromeos/login/users/mock_user_manager.h"
(...skipping 835 matching lines...) Expand 10 before | Expand all | Expand 10 after
883 884
884 EXPECT_EQ(dest_path2, profile_manager->GetLastUsedProfile()->GetPath()); 885 EXPECT_EQ(dest_path2, profile_manager->GetLastUsedProfile()->GetPath());
885 EXPECT_EQ(profile_name2, local_state->GetString(prefs::kProfileLastUsed)); 886 EXPECT_EQ(profile_name2, local_state->GetString(prefs::kProfileLastUsed));
886 } 887 }
887 888
888 TEST_F(ProfileManagerTest, ProfileDisplayNameResetsDefaultName) { 889 TEST_F(ProfileManagerTest, ProfileDisplayNameResetsDefaultName) {
889 if (!profiles::IsMultipleProfilesEnabled()) 890 if (!profiles::IsMultipleProfilesEnabled())
890 return; 891 return;
891 892
892 // The command line is reset at the end of every test by the test suite. 893 // The command line is reset at the end of every test by the test suite.
893 CommandLine::ForCurrentProcess()->AppendSwitch( 894 switches::EnableNewProfileManagementForTesting(
894 switches::kNewProfileManagement); 895 CommandLine::ForCurrentProcess());
895 896
896 ProfileManager* profile_manager = g_browser_process->profile_manager(); 897 ProfileManager* profile_manager = g_browser_process->profile_manager();
897 ProfileInfoCache& cache = profile_manager->GetProfileInfoCache(); 898 ProfileInfoCache& cache = profile_manager->GetProfileInfoCache();
898 EXPECT_EQ(0u, cache.GetNumberOfProfiles()); 899 EXPECT_EQ(0u, cache.GetNumberOfProfiles());
899 900
900 // Only one local profile means we display IDS_SINGLE_PROFILE_DISPLAY_NAME. 901 // Only one local profile means we display IDS_SINGLE_PROFILE_DISPLAY_NAME.
901 const base::string16 default_profile_name = 902 const base::string16 default_profile_name =
902 l10n_util::GetStringUTF16(IDS_SINGLE_PROFILE_DISPLAY_NAME); 903 l10n_util::GetStringUTF16(IDS_SINGLE_PROFILE_DISPLAY_NAME);
903 const base::string16 profile_name1 = cache.ChooseNameForNewProfile(0); 904 const base::string16 profile_name1 = cache.ChooseNameForNewProfile(0);
904 Profile* profile1 = AddProfileToCache(profile_manager, 905 Profile* profile1 = AddProfileToCache(profile_manager,
(...skipping 13 matching lines...) Expand all
918 // Spin the message loop so that all the callbacks can finish running. 919 // Spin the message loop so that all the callbacks can finish running.
919 base::RunLoop().RunUntilIdle(); 920 base::RunLoop().RunUntilIdle();
920 EXPECT_EQ(default_profile_name, profiles::GetAvatarNameForProfile(profile1)); 921 EXPECT_EQ(default_profile_name, profiles::GetAvatarNameForProfile(profile1));
921 } 922 }
922 923
923 TEST_F(ProfileManagerTest, ProfileDisplayNamePreservesCustomName) { 924 TEST_F(ProfileManagerTest, ProfileDisplayNamePreservesCustomName) {
924 if (!profiles::IsMultipleProfilesEnabled()) 925 if (!profiles::IsMultipleProfilesEnabled())
925 return; 926 return;
926 927
927 // The command line is reset at the end of every test by the test suite. 928 // The command line is reset at the end of every test by the test suite.
928 CommandLine::ForCurrentProcess()->AppendSwitch( 929 switches::EnableNewProfileManagementForTesting(
929 switches::kNewProfileManagement); 930 CommandLine::ForCurrentProcess());
930 931
931 ProfileManager* profile_manager = g_browser_process->profile_manager(); 932 ProfileManager* profile_manager = g_browser_process->profile_manager();
932 ProfileInfoCache& cache = profile_manager->GetProfileInfoCache(); 933 ProfileInfoCache& cache = profile_manager->GetProfileInfoCache();
933 EXPECT_EQ(0u, cache.GetNumberOfProfiles()); 934 EXPECT_EQ(0u, cache.GetNumberOfProfiles());
934 935
935 // Only one local profile means we display IDS_SINGLE_PROFILE_DISPLAY_NAME. 936 // Only one local profile means we display IDS_SINGLE_PROFILE_DISPLAY_NAME.
936 const base::string16 default_profile_name = 937 const base::string16 default_profile_name =
937 l10n_util::GetStringUTF16(IDS_SINGLE_PROFILE_DISPLAY_NAME); 938 l10n_util::GetStringUTF16(IDS_SINGLE_PROFILE_DISPLAY_NAME);
938 const base::string16 profile_name1 = cache.ChooseNameForNewProfile(0); 939 const base::string16 profile_name1 = cache.ChooseNameForNewProfile(0);
939 Profile* profile1 = AddProfileToCache(profile_manager, 940 Profile* profile1 = AddProfileToCache(profile_manager,
(...skipping 18 matching lines...) Expand all
958 ProfileManager::CreateCallback()); 959 ProfileManager::CreateCallback());
959 // Spin the message loop so that all the callbacks can finish running. 960 // Spin the message loop so that all the callbacks can finish running.
960 base::RunLoop().RunUntilIdle(); 961 base::RunLoop().RunUntilIdle();
961 EXPECT_EQ(custom_profile_name, profiles::GetAvatarNameForProfile(profile1)); 962 EXPECT_EQ(custom_profile_name, profiles::GetAvatarNameForProfile(profile1));
962 } 963 }
963 964
964 TEST_F(ProfileManagerTest, ProfileDisplayNamePreservesSignedInName) { 965 TEST_F(ProfileManagerTest, ProfileDisplayNamePreservesSignedInName) {
965 if (!profiles::IsMultipleProfilesEnabled()) 966 if (!profiles::IsMultipleProfilesEnabled())
966 return; 967 return;
967 968
968 // The command line is reset at the end of every test by the test suite. 969 // The command line is reset at the end of every test by the test suite.
969 CommandLine::ForCurrentProcess()->AppendSwitch( 970 switches::EnableNewProfileManagementForTesting(
970 switches::kNewProfileManagement); 971 CommandLine::ForCurrentProcess());
971 972
972 ProfileManager* profile_manager = g_browser_process->profile_manager(); 973 ProfileManager* profile_manager = g_browser_process->profile_manager();
973 ProfileInfoCache& cache = profile_manager->GetProfileInfoCache(); 974 ProfileInfoCache& cache = profile_manager->GetProfileInfoCache();
974 EXPECT_EQ(0u, cache.GetNumberOfProfiles()); 975 EXPECT_EQ(0u, cache.GetNumberOfProfiles());
975 976
976 // Only one local profile means we display IDS_SINGLE_PROFILE_DISPLAY_NAME. 977 // Only one local profile means we display IDS_SINGLE_PROFILE_DISPLAY_NAME.
977 const base::string16 default_profile_name = 978 const base::string16 default_profile_name =
978 l10n_util::GetStringUTF16(IDS_SINGLE_PROFILE_DISPLAY_NAME); 979 l10n_util::GetStringUTF16(IDS_SINGLE_PROFILE_DISPLAY_NAME);
979 const base::string16 profile_name1 = cache.ChooseNameForNewProfile(0); 980 const base::string16 profile_name1 = cache.ChooseNameForNewProfile(0);
980 Profile* profile1 = AddProfileToCache(profile_manager, 981 Profile* profile1 = AddProfileToCache(profile_manager,
(...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after
1101 dest_path2.BaseName().MaybeAsASCII()); 1102 dest_path2.BaseName().MaybeAsASCII());
1102 profile_manager->ScheduleProfileForDeletion(dest_path2, 1103 profile_manager->ScheduleProfileForDeletion(dest_path2,
1103 ProfileManager::CreateCallback()); 1104 ProfileManager::CreateCallback());
1104 // Spin the message loop so that all the callbacks can finish running. 1105 // Spin the message loop so that all the callbacks can finish running.
1105 base::RunLoop().RunUntilIdle(); 1106 base::RunLoop().RunUntilIdle();
1106 1107
1107 EXPECT_EQ(dest_path3, profile_manager->GetLastUsedProfile()->GetPath()); 1108 EXPECT_EQ(dest_path3, profile_manager->GetLastUsedProfile()->GetPath());
1108 EXPECT_EQ(profile_name3, local_state->GetString(prefs::kProfileLastUsed)); 1109 EXPECT_EQ(profile_name3, local_state->GetString(prefs::kProfileLastUsed));
1109 } 1110 }
1110 #endif // !defined(OS_MACOSX) 1111 #endif // !defined(OS_MACOSX)
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698