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 "chrome/browser/profiles/profile_list_desktop.h" | 5 #include "chrome/browser/profiles/profile_list_desktop.h" |
6 | 6 |
7 #include <string> | 7 #include <string> |
8 | 8 |
9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
10 #include "base/memory/scoped_ptr.h" | 10 #include "base/memory/scoped_ptr.h" |
(...skipping 264 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
275 base::FieldTrialList field_trial_list_(NULL); | 275 base::FieldTrialList field_trial_list_(NULL); |
276 base::FieldTrialList::CreateFieldTrial("ShowProfileSwitcher", "AlwaysShow"); | 276 base::FieldTrialList::CreateFieldTrial("ShowProfileSwitcher", "AlwaysShow"); |
277 | 277 |
278 #if defined(OS_CHROMEOS) | 278 #if defined(OS_CHROMEOS) |
279 EXPECT_FALSE(AvatarMenu::ShouldShowAvatarMenu()); | 279 EXPECT_FALSE(AvatarMenu::ShouldShowAvatarMenu()); |
280 #else | 280 #else |
281 EXPECT_TRUE(AvatarMenu::ShouldShowAvatarMenu()); | 281 EXPECT_TRUE(AvatarMenu::ShouldShowAvatarMenu()); |
282 #endif | 282 #endif |
283 } | 283 } |
284 | 284 |
285 TEST_F(ProfileListDesktopTest, DontShowOldAvatarMenuForSingleProfile) { | |
286 switches::DisableNewAvatarMenuForTesting( | |
287 base::CommandLine::ForCurrentProcess()); | |
288 | |
289 manager()->CreateTestingProfile("Test 1"); | |
290 | |
291 EXPECT_FALSE(AvatarMenu::ShouldShowAvatarMenu()); | |
292 | |
293 // If multiprofile mode is enabled, there are no other cases when we wouldn't | |
294 // show the menu. | |
295 if (profiles::IsMultipleProfilesEnabled()) | |
296 return; | |
297 | |
298 manager()->CreateTestingProfile("Test 2"); | |
299 | |
300 EXPECT_FALSE(AvatarMenu::ShouldShowAvatarMenu()); | |
301 } | |
302 | |
303 TEST_F(ProfileListDesktopTest, AlwaysShowNewAvatarMenu) { | |
304 // If multiprofile mode is not enabled then the menu is never shown. | |
305 if (!profiles::IsMultipleProfilesEnabled()) | |
306 return; | |
307 | |
308 switches::EnableNewAvatarMenuForTesting( | |
309 base::CommandLine::ForCurrentProcess()); | |
310 | |
311 manager()->CreateTestingProfile("Test 1"); | |
312 | |
313 EXPECT_TRUE(AvatarMenu::ShouldShowAvatarMenu()); | |
314 } | |
315 | |
316 TEST_F(ProfileListDesktopTest, ShowAvatarMenu) { | 285 TEST_F(ProfileListDesktopTest, ShowAvatarMenu) { |
317 // If multiprofile mode is not enabled then the menu is never shown. | 286 // If multiprofile mode is not enabled then the menu is never shown. |
318 if (!profiles::IsMultipleProfilesEnabled()) | 287 if (!profiles::IsMultipleProfilesEnabled()) |
319 return; | 288 return; |
320 | 289 |
321 manager()->CreateTestingProfile("Test 1"); | 290 manager()->CreateTestingProfile("Test 1"); |
322 manager()->CreateTestingProfile("Test 2"); | 291 manager()->CreateTestingProfile("Test 2"); |
323 | 292 |
324 #if defined(OS_CHROMEOS) | 293 #if defined(OS_CHROMEOS) |
325 EXPECT_FALSE(AvatarMenu::ShouldShowAvatarMenu()); | 294 EXPECT_FALSE(AvatarMenu::ShouldShowAvatarMenu()); |
(...skipping 26 matching lines...) Expand all Loading... |
352 base::string16 supervised_user_label = | 321 base::string16 supervised_user_label = |
353 l10n_util::GetStringUTF16(IDS_LEGACY_SUPERVISED_USER_AVATAR_LABEL); | 322 l10n_util::GetStringUTF16(IDS_LEGACY_SUPERVISED_USER_AVATAR_LABEL); |
354 const AvatarMenu::Item& item1 = model->GetItemAt(0); | 323 const AvatarMenu::Item& item1 = model->GetItemAt(0); |
355 EXPECT_NE(item1.username, supervised_user_label); | 324 EXPECT_NE(item1.username, supervised_user_label); |
356 | 325 |
357 const AvatarMenu::Item& item2 = model->GetItemAt(1); | 326 const AvatarMenu::Item& item2 = model->GetItemAt(1); |
358 EXPECT_EQ(item2.username, supervised_user_label); | 327 EXPECT_EQ(item2.username, supervised_user_label); |
359 } | 328 } |
360 | 329 |
361 } // namespace | 330 } // namespace |
OLD | NEW |