Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(200)

Side by Side Diff: chrome/browser/ui/cocoa/profiles/avatar_menu_bubble_controller_unittest.mm

Issue 1038423004: Reland of: Change default code flag to NewAvatarMenu. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: remove unneeded code from ProfileInfoCacheTest Created 5 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 #import "chrome/browser/ui/cocoa/profiles/avatar_menu_bubble_controller.h" 5 #import "chrome/browser/ui/cocoa/profiles/avatar_menu_bubble_controller.h"
6 6
7 #include "base/command_line.h"
7 #include "base/mac/scoped_nsobject.h" 8 #include "base/mac/scoped_nsobject.h"
8 #include "base/memory/scoped_ptr.h" 9 #include "base/memory/scoped_ptr.h"
9 #include "base/message_loop/message_pump_mac.h" 10 #include "base/message_loop/message_pump_mac.h"
10 #include "base/strings/utf_string_conversions.h" 11 #include "base/strings/utf_string_conversions.h"
11 #include "chrome/browser/prefs/pref_service_syncable.h" 12 #include "chrome/browser/prefs/pref_service_syncable.h"
12 #include "chrome/browser/profiles/avatar_menu.h" 13 #include "chrome/browser/profiles/avatar_menu.h"
13 #include "chrome/browser/profiles/avatar_menu_observer.h" 14 #include "chrome/browser/profiles/avatar_menu_observer.h"
14 #include "chrome/browser/profiles/profile_info_cache.h" 15 #include "chrome/browser/profiles/profile_info_cache.h"
15 #import "chrome/browser/ui/cocoa/cocoa_test_helper.h" 16 #import "chrome/browser/ui/cocoa/cocoa_test_helper.h"
16 #include "chrome/test/base/testing_browser_process.h" 17 #include "chrome/test/base/testing_browser_process.h"
17 #include "chrome/test/base/testing_profile_manager.h" 18 #include "chrome/test/base/testing_profile_manager.h"
19 #include "components/signin/core/common/profile_management_switches.h"
18 #include "testing/gtest_mac.h" 20 #include "testing/gtest_mac.h"
19 #import "ui/base/cocoa/controls/hyperlink_button_cell.h" 21 #import "ui/base/cocoa/controls/hyperlink_button_cell.h"
20 #include "ui/events/test/cocoa_test_event_utils.h" 22 #include "ui/events/test/cocoa_test_event_utils.h"
21 23
22 class AvatarMenuBubbleControllerTest : public CocoaTest { 24 class AvatarMenuBubbleControllerTest : public CocoaTest {
23 public: 25 public:
24 AvatarMenuBubbleControllerTest() 26 AvatarMenuBubbleControllerTest()
25 : manager_(TestingBrowserProcess::GetGlobal()) { 27 : manager_(TestingBrowserProcess::GetGlobal()) {
26 } 28 }
27 29
28 void SetUp() override { 30 void SetUp() override {
31 switches::DisableNewAvatarMenuForTesting(
32 base::CommandLine::ForCurrentProcess());
33
29 CocoaTest::SetUp(); 34 CocoaTest::SetUp();
30 ASSERT_TRUE(manager_.SetUp()); 35 ASSERT_TRUE(manager_.SetUp());
31 36
32 manager_.CreateTestingProfile("test1", scoped_ptr<PrefServiceSyncable>(), 37 manager_.CreateTestingProfile("test1", scoped_ptr<PrefServiceSyncable>(),
33 base::ASCIIToUTF16("Test 1"), 1, 38 base::ASCIIToUTF16("Test 1"), 1,
34 std::string(), 39 std::string(),
35 TestingProfile::TestingFactories()); 40 TestingProfile::TestingFactories());
36 manager_.CreateTestingProfile("test2", scoped_ptr<PrefServiceSyncable>(), 41 manager_.CreateTestingProfile("test2", scoped_ptr<PrefServiceSyncable>(),
37 base::ASCIIToUTF16("Test 2"), 0, 42 base::ASCIIToUTF16("Test 2"), 0,
38 std::string(), 43 std::string(),
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
71 AvatarMenu* menu_; 76 AvatarMenu* menu_;
72 }; 77 };
73 78
74 TEST_F(AvatarMenuBubbleControllerTest, InitialLayout) { 79 TEST_F(AvatarMenuBubbleControllerTest, InitialLayout) {
75 [controller() showWindow:nil]; 80 [controller() showWindow:nil];
76 81
77 // Two profiles means two item views and the new button with separator. 82 // Two profiles means two item views and the new button with separator.
78 NSView* contents = [[controller() window] contentView]; 83 NSView* contents = [[controller() window] contentView];
79 EXPECT_EQ(4U, [[contents subviews] count]); 84 EXPECT_EQ(4U, [[contents subviews] count]);
80 85
81 // Loop over the itmes and match the viewController views to subviews. 86 // Loop over the items and match the viewController views to subviews.
82 NSMutableArray* subviews = 87 NSMutableArray* subviews =
83 [NSMutableArray arrayWithArray:[contents subviews]]; 88 [NSMutableArray arrayWithArray:[contents subviews]];
84 for (AvatarMenuItemController* viewController in [controller() items]) { 89 for (AvatarMenuItemController* viewController in [controller() items]) {
85 for (NSView* subview in subviews) { 90 for (NSView* subview in subviews) {
86 if ([viewController view] == subview) { 91 if ([viewController view] == subview) {
87 [subviews removeObject:subview]; 92 [subviews removeObject:subview];
88 break; 93 break;
89 } 94 }
90 } 95 }
91 } 96 }
(...skipping 169 matching lines...) Expand 10 before | Expand all | Expand 10 after
261 [controller() keyDown:event]; 266 [controller() keyDown:event];
262 EXPECT_EQ([[controller() items] objectAtIndex:0], GetHighlightedItem()); 267 EXPECT_EQ([[controller() items] objectAtIndex:0], GetHighlightedItem());
263 268
264 [controller() keyDown:event]; 269 [controller() keyDown:event];
265 EXPECT_EQ([[controller() items] objectAtIndex:1], GetHighlightedItem()); 270 EXPECT_EQ([[controller() items] objectAtIndex:1], GetHighlightedItem());
266 271
267 // There are no more items now so going up should stay at the first item. 272 // There are no more items now so going up should stay at the first item.
268 [controller() keyDown:event]; 273 [controller() keyDown:event];
269 EXPECT_EQ([[controller() items] objectAtIndex:1], GetHighlightedItem()); 274 EXPECT_EQ([[controller() items] objectAtIndex:1], GetHighlightedItem());
270 } 275 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698