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

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

Issue 59883010: This is the fourth CL of several that will eventually replace TokenService with (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Change LOG(INFO) to VLOG(1) Created 7 years 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 | Annotate | Revision Log
OLDNEW
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 #import "chrome/browser/ui/cocoa/browser/avatar_menu_bubble_controller.h" 5 #import "chrome/browser/ui/cocoa/browser/avatar_menu_bubble_controller.h"
6 6
7 #include "base/mac/scoped_nsobject.h" 7 #include "base/mac/scoped_nsobject.h"
8 #include "base/memory/scoped_ptr.h" 8 #include "base/memory/scoped_ptr.h"
9 #include "base/message_loop/message_pump_mac.h" 9 #include "base/message_loop/message_pump_mac.h"
10 #include "base/strings/utf_string_conversions.h" 10 #include "base/strings/utf_string_conversions.h"
(...skipping 12 matching lines...) Expand all
23 public: 23 public:
24 AvatarMenuBubbleControllerTest() 24 AvatarMenuBubbleControllerTest()
25 : manager_(TestingBrowserProcess::GetGlobal()) { 25 : manager_(TestingBrowserProcess::GetGlobal()) {
26 } 26 }
27 27
28 virtual void SetUp() { 28 virtual void SetUp() {
29 CocoaTest::SetUp(); 29 CocoaTest::SetUp();
30 ASSERT_TRUE(manager_.SetUp()); 30 ASSERT_TRUE(manager_.SetUp());
31 31
32 manager_.CreateTestingProfile("test1", scoped_ptr<PrefServiceSyncable>(), 32 manager_.CreateTestingProfile("test1", scoped_ptr<PrefServiceSyncable>(),
33 ASCIIToUTF16("Test 1"), 1, std::string()); 33 ASCIIToUTF16("Test 1"), 1, std::string(),
34 TestingProfile::TestingFactories());
34 manager_.CreateTestingProfile("test2", scoped_ptr<PrefServiceSyncable>(), 35 manager_.CreateTestingProfile("test2", scoped_ptr<PrefServiceSyncable>(),
35 ASCIIToUTF16("Test 2"), 0, std::string()); 36 ASCIIToUTF16("Test 2"), 0, std::string(),
37 TestingProfile::TestingFactories());
36 38
37 menu_ = new AvatarMenu(manager_.profile_info_cache(), NULL, NULL); 39 menu_ = new AvatarMenu(manager_.profile_info_cache(), NULL, NULL);
38 menu_->RebuildMenu(); 40 menu_->RebuildMenu();
39 41
40 NSRect frame = [test_window() frame]; 42 NSRect frame = [test_window() frame];
41 NSPoint point = NSMakePoint(NSMidX(frame), NSMidY(frame)); 43 NSPoint point = NSMakePoint(NSMidX(frame), NSMidY(frame));
42 controller_ = 44 controller_ =
43 [[AvatarMenuBubbleController alloc] initWithMenu:menu() 45 [[AvatarMenuBubbleController alloc] initWithMenu:menu()
44 parentWindow:test_window() 46 parentWindow:test_window()
45 anchoredAt:point]; 47 anchoredAt:point];
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after
115 TEST_F(AvatarMenuBubbleControllerTest, PerformLayout) { 117 TEST_F(AvatarMenuBubbleControllerTest, PerformLayout) {
116 [controller() showWindow:nil]; 118 [controller() showWindow:nil];
117 119
118 NSView* contents = [[controller() window] contentView]; 120 NSView* contents = [[controller() window] contentView];
119 EXPECT_EQ(4U, [[contents subviews] count]); 121 EXPECT_EQ(4U, [[contents subviews] count]);
120 122
121 base::scoped_nsobject<NSMutableArray> oldItems([[controller() items] copy]); 123 base::scoped_nsobject<NSMutableArray> oldItems([[controller() items] copy]);
122 124
123 // Now create a new profile and notify the delegate. 125 // Now create a new profile and notify the delegate.
124 manager()->CreateTestingProfile("test3", scoped_ptr<PrefServiceSyncable>(), 126 manager()->CreateTestingProfile("test3", scoped_ptr<PrefServiceSyncable>(),
125 ASCIIToUTF16("Test 3"), 0, std::string()); 127 ASCIIToUTF16("Test 3"), 0, std::string(),
128 TestingProfile::TestingFactories());
126 129
127 // Testing the bridge is not worth the effort... 130 // Testing the bridge is not worth the effort...
128 [controller() performLayout]; 131 [controller() performLayout];
129 132
130 EXPECT_EQ(5U, [[contents subviews] count]); 133 EXPECT_EQ(5U, [[contents subviews] count]);
131 134
132 // Make sure that none of the old items exit. 135 // Make sure that none of the old items exit.
133 NSArray* newItems = [controller() items]; 136 NSArray* newItems = [controller() items];
134 for (AvatarMenuItemController* oldVC in oldItems.get()) { 137 for (AvatarMenuItemController* oldVC in oldItems.get()) {
135 EXPECT_FALSE([newItems containsObject:oldVC]); 138 EXPECT_FALSE([newItems containsObject:oldVC]);
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after
255 [controller() keyDown:event]; 258 [controller() keyDown:event];
256 EXPECT_EQ([[controller() items] objectAtIndex:0], GetHighlightedItem()); 259 EXPECT_EQ([[controller() items] objectAtIndex:0], GetHighlightedItem());
257 260
258 [controller() keyDown:event]; 261 [controller() keyDown:event];
259 EXPECT_EQ([[controller() items] objectAtIndex:1], GetHighlightedItem()); 262 EXPECT_EQ([[controller() items] objectAtIndex:1], GetHighlightedItem());
260 263
261 // There are no more items now so going up should stay at the first item. 264 // There are no more items now so going up should stay at the first item.
262 [controller() keyDown:event]; 265 [controller() keyDown:event];
263 EXPECT_EQ([[controller() items] objectAtIndex:1], GetHighlightedItem()); 266 EXPECT_EQ([[controller() items] objectAtIndex:1], GetHighlightedItem());
264 } 267 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698