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 "base/bind.h" | 5 #include "base/bind.h" |
6 #include "chrome/browser/profiles/profile_info_cache.h" | 6 #include "chrome/browser/profiles/profile_info_cache.h" |
7 #include "chrome/browser/profiles/profile_manager.h" | 7 #include "chrome/browser/profiles/profile_manager.h" |
8 #include "chrome/test/base/in_process_browser_test.h" | 8 #include "chrome/test/base/in_process_browser_test.h" |
9 #include "chrome/test/base/testing_browser_process.h" | 9 #include "chrome/test/base/testing_browser_process.h" |
10 #include "chrome/test/base/ui_test_utils.h" | 10 #include "chrome/test/base/ui_test_utils.h" |
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
71 ProfileInfoCache& cache = profile_manager->GetProfileInfoCache(); | 71 ProfileInfoCache& cache = profile_manager->GetProfileInfoCache(); |
72 | 72 |
73 // Create an additional profile. | 73 // Create an additional profile. |
74 FilePath new_path = profile_manager->GenerateNextProfileDirectoryPath(); | 74 FilePath new_path = profile_manager->GenerateNextProfileDirectoryPath(); |
75 profile_manager->CreateProfileAsync(new_path, | 75 profile_manager->CreateProfileAsync(new_path, |
76 base::Bind(&OnUnblockOnProfileCreation), | 76 base::Bind(&OnUnblockOnProfileCreation), |
77 string16(), string16()); | 77 string16(), string16()); |
78 | 78 |
79 // Spin to allow profile creation to take place, loop is terminated | 79 // Spin to allow profile creation to take place, loop is terminated |
80 // by OnUnblockOnProfileCreation when the profile is created. | 80 // by OnUnblockOnProfileCreation when the profile is created. |
81 ui_test_utils::RunMessageLoop(); | 81 content::RunMessageLoop(); |
82 | 82 |
83 ASSERT_EQ(cache.GetNumberOfProfiles(), 2U); | 83 ASSERT_EQ(cache.GetNumberOfProfiles(), 2U); |
84 | 84 |
85 // Delete all profiles. | 85 // Delete all profiles. |
86 FilePath profile_path1 = cache.GetPathOfProfileAtIndex(0); | 86 FilePath profile_path1 = cache.GetPathOfProfileAtIndex(0); |
87 FilePath profile_path2 = cache.GetPathOfProfileAtIndex(1); | 87 FilePath profile_path2 = cache.GetPathOfProfileAtIndex(1); |
88 EXPECT_FALSE(profile_path1.empty()); | 88 EXPECT_FALSE(profile_path1.empty()); |
89 EXPECT_FALSE(profile_path2.empty()); | 89 EXPECT_FALSE(profile_path2.empty()); |
90 profile_manager->ScheduleProfileForDeletion(profile_path1); | 90 profile_manager->ScheduleProfileForDeletion(profile_path1); |
91 profile_manager->ScheduleProfileForDeletion(profile_path2); | 91 profile_manager->ScheduleProfileForDeletion(profile_path2); |
92 | 92 |
93 // Spin things so deletion can take place. | 93 // Spin things so deletion can take place. |
94 ui_test_utils::RunAllPendingInMessageLoop(); | 94 ui_test_utils::RunAllPendingInMessageLoop(); |
95 | 95 |
96 // Make sure a new profile was created automatically. | 96 // Make sure a new profile was created automatically. |
97 EXPECT_EQ(cache.GetNumberOfProfiles(), 1U); | 97 EXPECT_EQ(cache.GetNumberOfProfiles(), 1U); |
98 FilePath new_profile_path = cache.GetPathOfProfileAtIndex(0); | 98 FilePath new_profile_path = cache.GetPathOfProfileAtIndex(0); |
99 EXPECT_NE(new_profile_path, profile_path1); | 99 EXPECT_NE(new_profile_path, profile_path1); |
100 EXPECT_NE(new_profile_path, profile_path2); | 100 EXPECT_NE(new_profile_path, profile_path2); |
101 | 101 |
102 // Make sure that last used profile preference is set correctly. | 102 // Make sure that last used profile preference is set correctly. |
103 Profile* last_used = ProfileManager::GetLastUsedProfile(); | 103 Profile* last_used = ProfileManager::GetLastUsedProfile(); |
104 EXPECT_EQ(new_profile_path, last_used->GetPath()); | 104 EXPECT_EQ(new_profile_path, last_used->GetPath()); |
105 } | 105 } |
106 #endif // OS_MACOSX | 106 #endif // OS_MACOSX |
OLD | NEW |