| OLD | NEW |
| 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 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 <stddef.h> | 5 #include <stddef.h> |
| 6 | 6 |
| 7 #include "base/command_line.h" | 7 #include "base/command_line.h" |
| 8 #include "base/macros.h" | 8 #include "base/macros.h" |
| 9 #include "build/build_config.h" | 9 #include "build/build_config.h" |
| 10 #include "chrome/browser/chrome_notification_types.h" | 10 #include "chrome/browser/chrome_notification_types.h" |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 62 return; | 62 return; |
| 63 | 63 |
| 64 ProfileManager* profile_manager = g_browser_process->profile_manager(); | 64 ProfileManager* profile_manager = g_browser_process->profile_manager(); |
| 65 Profile* current_profile = browser()->profile(); | 65 Profile* current_profile = browser()->profile(); |
| 66 ProfileInfoCache& cache = profile_manager->GetProfileInfoCache(); | 66 ProfileInfoCache& cache = profile_manager->GetProfileInfoCache(); |
| 67 size_t index = cache.GetIndexOfProfileWithPath(current_profile->GetPath()); | 67 size_t index = cache.GetIndexOfProfileWithPath(current_profile->GetPath()); |
| 68 | 68 |
| 69 scoped_ptr<AvatarMenu> menu = CreateAvatarMenu(&cache); | 69 scoped_ptr<AvatarMenu> menu = CreateAvatarMenu(&cache); |
| 70 menu->RebuildMenu(); | 70 menu->RebuildMenu(); |
| 71 | 71 |
| 72 BrowserList* browser_list = | 72 BrowserList* browser_list = BrowserList::GetInstance(); |
| 73 BrowserList::GetInstance(chrome::GetActiveDesktop()); | |
| 74 EXPECT_EQ(1U, browser_list->size()); | 73 EXPECT_EQ(1U, browser_list->size()); |
| 75 content::WindowedNotificationObserver window_close_observer( | 74 content::WindowedNotificationObserver window_close_observer( |
| 76 chrome::NOTIFICATION_BROWSER_CLOSED, | 75 chrome::NOTIFICATION_BROWSER_CLOSED, |
| 77 content::Source<Browser>(browser())); | 76 content::Source<Browser>(browser())); |
| 78 | 77 |
| 79 EXPECT_FALSE(cache.ProfileIsSigninRequiredAtIndex(index)); | 78 EXPECT_FALSE(cache.ProfileIsSigninRequiredAtIndex(index)); |
| 80 profiles::LockProfile(current_profile); | 79 profiles::LockProfile(current_profile); |
| 81 window_close_observer.Wait(); // rely on test time-out for failure indication | 80 window_close_observer.Wait(); // rely on test time-out for failure indication |
| 82 | 81 |
| 83 EXPECT_TRUE(cache.ProfileIsSigninRequiredAtIndex(index)); | 82 EXPECT_TRUE(cache.ProfileIsSigninRequiredAtIndex(index)); |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 119 base::string16(), std::string(), | 118 base::string16(), std::string(), |
| 120 std::string()); | 119 std::string()); |
| 121 | 120 |
| 122 // Spin to allow profile creation to take place, loop is terminated | 121 // Spin to allow profile creation to take place, loop is terminated |
| 123 // by OnUnblockOnProfileCreation when the profile is created. | 122 // by OnUnblockOnProfileCreation when the profile is created. |
| 124 content::RunMessageLoop(); | 123 content::RunMessageLoop(); |
| 125 ASSERT_EQ(cache.GetNumberOfProfiles(), 2U); | 124 ASSERT_EQ(cache.GetNumberOfProfiles(), 2U); |
| 126 | 125 |
| 127 scoped_ptr<AvatarMenu> menu = CreateAvatarMenu(&cache); | 126 scoped_ptr<AvatarMenu> menu = CreateAvatarMenu(&cache); |
| 128 menu->RebuildMenu(); | 127 menu->RebuildMenu(); |
| 129 BrowserList* browser_list = | 128 BrowserList* browser_list = BrowserList::GetInstance(); |
| 130 BrowserList::GetInstance(chrome::GetActiveDesktop()); | |
| 131 EXPECT_EQ(1U, browser_list->size()); | 129 EXPECT_EQ(1U, browser_list->size()); |
| 132 EXPECT_EQ(path_profile1, browser_list->get(0)->profile()->GetPath()); | 130 EXPECT_EQ(path_profile1, browser_list->get(0)->profile()->GetPath()); |
| 133 | 131 |
| 134 // Open a browser window for the first profile. | 132 // Open a browser window for the first profile. |
| 135 menu->SwitchToProfile(cache.GetIndexOfProfileWithPath(path_profile1), | 133 menu->SwitchToProfile(cache.GetIndexOfProfileWithPath(path_profile1), |
| 136 false, ProfileMetrics::SWITCH_PROFILE_ICON); | 134 false, ProfileMetrics::SWITCH_PROFILE_ICON); |
| 137 EXPECT_EQ(1U, browser_list->size()); | 135 EXPECT_EQ(1U, browser_list->size()); |
| 138 EXPECT_EQ(path_profile1, browser_list->get(0)->profile()->GetPath()); | 136 EXPECT_EQ(path_profile1, browser_list->get(0)->profile()->GetPath()); |
| 139 | 137 |
| 140 // Open a browser window for the second profile. | 138 // Open a browser window for the second profile. |
| 141 menu->SwitchToProfile(cache.GetIndexOfProfileWithPath(path_profile2), | 139 menu->SwitchToProfile(cache.GetIndexOfProfileWithPath(path_profile2), |
| 142 false, ProfileMetrics::SWITCH_PROFILE_ICON); | 140 false, ProfileMetrics::SWITCH_PROFILE_ICON); |
| 143 EXPECT_EQ(2U, browser_list->size()); | 141 EXPECT_EQ(2U, browser_list->size()); |
| 144 | 142 |
| 145 // Switch to the first profile without opening a new window. | 143 // Switch to the first profile without opening a new window. |
| 146 menu->SwitchToProfile(cache.GetIndexOfProfileWithPath(path_profile1), | 144 menu->SwitchToProfile(cache.GetIndexOfProfileWithPath(path_profile1), |
| 147 false, ProfileMetrics::SWITCH_PROFILE_ICON); | 145 false, ProfileMetrics::SWITCH_PROFILE_ICON); |
| 148 EXPECT_EQ(2U, browser_list->size()); | 146 EXPECT_EQ(2U, browser_list->size()); |
| 149 EXPECT_EQ(path_profile1, browser_list->get(0)->profile()->GetPath()); | 147 EXPECT_EQ(path_profile1, browser_list->get(0)->profile()->GetPath()); |
| 150 EXPECT_EQ(path_profile2, browser_list->get(1)->profile()->GetPath()); | 148 EXPECT_EQ(path_profile2, browser_list->get(1)->profile()->GetPath()); |
| 151 } | 149 } |
| OLD | NEW |