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