| 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 "base/command_line.h" | 5 #include "base/command_line.h" |
| 6 #include "base/path_service.h" | 6 #include "base/path_service.h" |
| 7 #include "chrome/browser/chrome_notification_types.h" | 7 #include "chrome/browser/chrome_notification_types.h" |
| 8 #include "chrome/browser/profiles/avatar_menu.h" | 8 #include "chrome/browser/profiles/avatar_menu.h" |
| 9 #include "chrome/browser/profiles/profile_manager.h" | 9 #include "chrome/browser/profiles/profile_manager.h" |
| 10 #include "chrome/browser/profiles/profile_window.h" | 10 #include "chrome/browser/profiles/profile_window.h" |
| (...skipping 16 matching lines...) Expand all Loading... |
| 27 if (status == Profile::CREATE_STATUS_INITIALIZED) | 27 if (status == Profile::CREATE_STATUS_INITIALIZED) |
| 28 base::MessageLoop::current()->Quit(); | 28 base::MessageLoop::current()->Quit(); |
| 29 } | 29 } |
| 30 | 30 |
| 31 } // namespace | 31 } // namespace |
| 32 | 32 |
| 33 class ProfileListDesktopBrowserTest : public InProcessBrowserTest { | 33 class ProfileListDesktopBrowserTest : public InProcessBrowserTest { |
| 34 public: | 34 public: |
| 35 ProfileListDesktopBrowserTest() {} | 35 ProfileListDesktopBrowserTest() {} |
| 36 | 36 |
| 37 AvatarMenu* GetAvatarMenu(ProfileInfoCache* cache) { | 37 scoped_ptr<AvatarMenu> CreateAvatarMenu(ProfileInfoCache* cache) { |
| 38 // Reset the menu. | 38 return scoped_ptr<AvatarMenu>(new AvatarMenu(cache, NULL, browser())); |
| 39 avatar_menu_.reset(new AvatarMenu( | |
| 40 cache, | |
| 41 NULL, | |
| 42 browser())); | |
| 43 return avatar_menu_.get(); | |
| 44 } | 39 } |
| 45 | 40 |
| 46 private: | 41 private: |
| 47 scoped_ptr<AvatarMenu> avatar_menu_; | 42 scoped_ptr<AvatarMenu> avatar_menu_; |
| 48 | 43 |
| 49 DISALLOW_COPY_AND_ASSIGN(ProfileListDesktopBrowserTest); | 44 DISALLOW_COPY_AND_ASSIGN(ProfileListDesktopBrowserTest); |
| 50 }; | 45 }; |
| 51 | 46 |
| 52 #if defined(OS_WIN) | 47 #if defined(OS_WIN) |
| 53 // SignOut is flaky. So far only observed on Windows. crbug.com/357329. | 48 // SignOut is flaky. So far only observed on Windows. crbug.com/357329. |
| 54 #define MAYBE_SignOut DISABLED_SignOut | 49 #define MAYBE_SignOut DISABLED_SignOut |
| 55 #elif defined(OS_CHROMEOS) | 50 #elif defined(OS_CHROMEOS) |
| 56 // This test doesn't make sense for Chrome OS since it has a different | 51 // This test doesn't make sense for Chrome OS since it has a different |
| 57 // multi-profiles menu in the system tray instead. | 52 // multi-profiles menu in the system tray instead. |
| 58 #define MAYBE_SignOut DISABLED_SignOut | 53 #define MAYBE_SignOut DISABLED_SignOut |
| 59 #else | 54 #else |
| 60 #define MAYBE_SignOut SignOut | 55 #define MAYBE_SignOut SignOut |
| 61 #endif | 56 #endif |
| 62 IN_PROC_BROWSER_TEST_F(ProfileListDesktopBrowserTest, MAYBE_SignOut) { | 57 IN_PROC_BROWSER_TEST_F(ProfileListDesktopBrowserTest, MAYBE_SignOut) { |
| 63 if (!profiles::IsMultipleProfilesEnabled()) | 58 if (!profiles::IsMultipleProfilesEnabled()) |
| 64 return; | 59 return; |
| 65 | 60 |
| 66 ProfileManager* profile_manager = g_browser_process->profile_manager(); | 61 ProfileManager* profile_manager = g_browser_process->profile_manager(); |
| 67 Profile* current_profile = browser()->profile(); | 62 Profile* current_profile = browser()->profile(); |
| 68 ProfileInfoCache& cache = profile_manager->GetProfileInfoCache(); | 63 ProfileInfoCache& cache = profile_manager->GetProfileInfoCache(); |
| 69 size_t index = cache.GetIndexOfProfileWithPath(current_profile->GetPath()); | 64 size_t index = cache.GetIndexOfProfileWithPath(current_profile->GetPath()); |
| 70 | 65 |
| 71 AvatarMenu* menu = GetAvatarMenu(&cache); | 66 scoped_ptr<AvatarMenu> menu = CreateAvatarMenu(&cache); |
| 72 menu->RebuildMenu(); | 67 menu->RebuildMenu(); |
| 73 | 68 |
| 74 BrowserList* browser_list = | 69 BrowserList* browser_list = |
| 75 BrowserList::GetInstance(chrome::GetActiveDesktop()); | 70 BrowserList::GetInstance(chrome::GetActiveDesktop()); |
| 76 EXPECT_EQ(1U, browser_list->size()); | 71 EXPECT_EQ(1U, browser_list->size()); |
| 77 content::WindowedNotificationObserver window_close_observer( | 72 content::WindowedNotificationObserver window_close_observer( |
| 78 chrome::NOTIFICATION_BROWSER_CLOSED, | 73 chrome::NOTIFICATION_BROWSER_CLOSED, |
| 79 content::Source<Browser>(browser())); | 74 content::Source<Browser>(browser())); |
| 80 | 75 |
| 81 EXPECT_FALSE(cache.ProfileIsSigninRequiredAtIndex(index)); | 76 EXPECT_FALSE(cache.ProfileIsSigninRequiredAtIndex(index)); |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 118 profile_manager->CreateProfileAsync(path_profile2, | 113 profile_manager->CreateProfileAsync(path_profile2, |
| 119 base::Bind(&OnUnblockOnProfileCreation), | 114 base::Bind(&OnUnblockOnProfileCreation), |
| 120 base::string16(), base::string16(), | 115 base::string16(), base::string16(), |
| 121 std::string()); | 116 std::string()); |
| 122 | 117 |
| 123 // Spin to allow profile creation to take place, loop is terminated | 118 // Spin to allow profile creation to take place, loop is terminated |
| 124 // by OnUnblockOnProfileCreation when the profile is created. | 119 // by OnUnblockOnProfileCreation when the profile is created. |
| 125 content::RunMessageLoop(); | 120 content::RunMessageLoop(); |
| 126 ASSERT_EQ(cache.GetNumberOfProfiles(), 2U); | 121 ASSERT_EQ(cache.GetNumberOfProfiles(), 2U); |
| 127 | 122 |
| 128 AvatarMenu* menu = GetAvatarMenu(&cache); | 123 scoped_ptr<AvatarMenu> menu = CreateAvatarMenu(&cache); |
| 129 menu->RebuildMenu(); | 124 menu->RebuildMenu(); |
| 130 BrowserList* browser_list = | 125 BrowserList* browser_list = |
| 131 BrowserList::GetInstance(chrome::GetActiveDesktop()); | 126 BrowserList::GetInstance(chrome::GetActiveDesktop()); |
| 132 EXPECT_EQ(1U, browser_list->size()); | 127 EXPECT_EQ(1U, browser_list->size()); |
| 133 EXPECT_EQ(path_profile1, browser_list->get(0)->profile()->GetPath()); | 128 EXPECT_EQ(path_profile1, browser_list->get(0)->profile()->GetPath()); |
| 134 | 129 |
| 135 // Open a browser window for the first profile. | 130 // Open a browser window for the first profile. |
| 136 menu->SwitchToProfile(cache.GetIndexOfProfileWithPath(path_profile1), | 131 menu->SwitchToProfile(cache.GetIndexOfProfileWithPath(path_profile1), |
| 137 false, ProfileMetrics::SWITCH_PROFILE_ICON); | 132 false, ProfileMetrics::SWITCH_PROFILE_ICON); |
| 138 EXPECT_EQ(1U, browser_list->size()); | 133 EXPECT_EQ(1U, browser_list->size()); |
| 139 EXPECT_EQ(path_profile1, browser_list->get(0)->profile()->GetPath()); | 134 EXPECT_EQ(path_profile1, browser_list->get(0)->profile()->GetPath()); |
| 140 | 135 |
| 141 // Open a browser window for the second profile. | 136 // Open a browser window for the second profile. |
| 142 menu->SwitchToProfile(cache.GetIndexOfProfileWithPath(path_profile2), | 137 menu->SwitchToProfile(cache.GetIndexOfProfileWithPath(path_profile2), |
| 143 false, ProfileMetrics::SWITCH_PROFILE_ICON); | 138 false, ProfileMetrics::SWITCH_PROFILE_ICON); |
| 144 EXPECT_EQ(2U, browser_list->size()); | 139 EXPECT_EQ(2U, browser_list->size()); |
| 145 | 140 |
| 146 // Switch to the first profile without opening a new window. | 141 // Switch to the first profile without opening a new window. |
| 147 menu->SwitchToProfile(cache.GetIndexOfProfileWithPath(path_profile1), | 142 menu->SwitchToProfile(cache.GetIndexOfProfileWithPath(path_profile1), |
| 148 false, ProfileMetrics::SWITCH_PROFILE_ICON); | 143 false, ProfileMetrics::SWITCH_PROFILE_ICON); |
| 149 EXPECT_EQ(2U, browser_list->size()); | 144 EXPECT_EQ(2U, browser_list->size()); |
| 150 EXPECT_EQ(path_profile1, browser_list->get(0)->profile()->GetPath()); | 145 EXPECT_EQ(path_profile1, browser_list->get(0)->profile()->GetPath()); |
| 151 EXPECT_EQ(path_profile2, browser_list->get(1)->profile()->GetPath()); | 146 EXPECT_EQ(path_profile2, browser_list->get(1)->profile()->GetPath()); |
| 152 } | 147 } |
| OLD | NEW |