Chromium Code Reviews

Side by Side Diff: chrome/browser/cocoa/bookmark_bar_controller_unittest.mm

Issue 373022: Enable and implement last 2 items in bookmark bar context menu: "Open... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 11 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View unified diff | | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2009 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 <Cocoa/Cocoa.h> 5 #import <Cocoa/Cocoa.h>
6 6
7 #include "base/basictypes.h" 7 #include "base/basictypes.h"
8 #include "base/scoped_nsobject.h" 8 #include "base/scoped_nsobject.h"
9 #include "base/sys_string_conversions.h" 9 #include "base/sys_string_conversions.h"
10 #import "chrome/browser/cocoa/bookmark_bar_constants.h" 10 #import "chrome/browser/cocoa/bookmark_bar_constants.h"
11 #import "chrome/browser/cocoa/bookmark_bar_controller.h" 11 #import "chrome/browser/cocoa/bookmark_bar_controller.h"
12 #import "chrome/browser/cocoa/bookmark_bar_view.h" 12 #import "chrome/browser/cocoa/bookmark_bar_view.h"
13 #include "chrome/browser/cocoa/browser_test_helper.h" 13 #include "chrome/browser/cocoa/browser_test_helper.h"
14 #import "chrome/browser/cocoa/cocoa_test_helper.h" 14 #import "chrome/browser/cocoa/cocoa_test_helper.h"
15 #import "chrome/browser/cocoa/toolbar_compressable.h" 15 #import "chrome/browser/cocoa/toolbar_compressable.h"
16 #include "chrome/browser/cocoa/test_event_utils.h" 16 #include "chrome/browser/cocoa/test_event_utils.h"
17 #import "chrome/browser/cocoa/view_resizer_pong.h" 17 #import "chrome/browser/cocoa/view_resizer_pong.h"
18 #include "chrome/common/pref_names.h" 18 #include "chrome/common/pref_names.h"
19 #include "testing/gtest/include/gtest/gtest.h" 19 #include "testing/gtest/include/gtest/gtest.h"
20 #include "testing/platform_test.h" 20 #include "testing/platform_test.h"
21 21
22 // Pretend BookmarkURLOpener delegate to keep track of requests 22 // Just like a BookmarkBarController but openURL: is stubbed out.
23 @interface BookmarkURLOpenerPong : NSObject<BookmarkURLOpener> { 23 @interface BookmarkBarControllerNoOpen : BookmarkBarController {
24 @public 24 @public
25 std::vector<GURL> urls_; 25 std::vector<GURL> urls_;
26 std::vector<WindowOpenDisposition> dispositions_; 26 std::vector<WindowOpenDisposition> dispositions_;
27 } 27 }
28 @end 28 @end
29 29
30 @implementation BookmarkURLOpenerPong 30 @implementation BookmarkBarControllerNoOpen
31 - (void)openBookmarkURL:(const GURL&)url 31 - (void)openURL:(GURL)url disposition:(WindowOpenDisposition)disposition {
32 disposition:(WindowOpenDisposition)disposition {
33 urls_.push_back(url); 32 urls_.push_back(url);
34 dispositions_.push_back(disposition); 33 dispositions_.push_back(disposition);
35 } 34 }
36 - (void)clear { 35 - (void)clear {
37 urls_.clear(); 36 urls_.clear();
38 dispositions_.clear(); 37 dispositions_.clear();
39 } 38 }
40 @end 39 @end
41 40
42 41
(...skipping 13 matching lines...)
56 - (id)initTextCell:(NSString*)string desiredSize:(NSSize)size { 55 - (id)initTextCell:(NSString*)string desiredSize:(NSSize)size {
57 if ((self = [super initTextCell:string])) { 56 if ((self = [super initTextCell:string])) {
58 cellSize_ = size; 57 cellSize_ = size;
59 } 58 }
60 return self; 59 return self;
61 } 60 }
62 61
63 @end 62 @end
64 63
65 // Remember the number of times we've gotten a frameDidChange notification. 64 // Remember the number of times we've gotten a frameDidChange notification.
66 @interface BookmarkBarControllerTogglePong : BookmarkBarController { 65 @interface BookmarkBarControllerTogglePong : BookmarkBarControllerNoOpen {
67 @private 66 @private
68 int toggles_; 67 int toggles_;
69 } 68 }
70 @property (readonly) int toggles; 69 @property (readonly) int toggles;
71 @end 70 @end
72 71
73 @implementation BookmarkBarControllerTogglePong 72 @implementation BookmarkBarControllerTogglePong
74 73
75 @synthesize toggles = toggles_; 74 @synthesize toggles = toggles_;
76 75
77 - (void)frameDidChange { 76 - (void)frameDidChange {
78 toggles_++; 77 toggles_++;
79 } 78 }
80 79
81 @end 80 @end
82 81
83 // A BookmarkBarController that always beleives that it's on the new tab page. 82 // A BookmarkBarController that always beleives that it's on the new tab page.
84 @interface AlwaysNewTabPageBookmarkBarController : BookmarkBarController { 83 @interface AlwaysNewTabPageBookmarkBarController : BookmarkBarControllerNoOpen {
85 } 84 }
86 @end 85 @end
87 86
88 @implementation AlwaysNewTabPageBookmarkBarController 87 @implementation AlwaysNewTabPageBookmarkBarController
89 -(BOOL)isNewTabPage { 88 -(BOOL)isNewTabPage {
90 return YES; 89 return YES;
91 } 90 }
92 @end 91 @end
93 92
94 @interface CompressablePong : NSObject<ToolbarCompressable> { 93 @interface CompressablePong : NSObject<ToolbarCompressable> {
(...skipping 20 matching lines...)
115 114
116 class BookmarkBarControllerTest : public PlatformTest { 115 class BookmarkBarControllerTest : public PlatformTest {
117 public: 116 public:
118 BookmarkBarControllerTest() { 117 BookmarkBarControllerTest() {
119 resizeDelegate_.reset([[ViewResizerPong alloc] init]); 118 resizeDelegate_.reset([[ViewResizerPong alloc] init]);
120 compressDelegate_.reset([[CompressablePong alloc] init]); 119 compressDelegate_.reset([[CompressablePong alloc] init]);
121 NSRect parent_frame = NSMakeRect(0, 0, 800, 50); 120 NSRect parent_frame = NSMakeRect(0, 0, 800, 50);
122 parent_view_.reset([[NSView alloc] initWithFrame:parent_frame]); 121 parent_view_.reset([[NSView alloc] initWithFrame:parent_frame]);
123 [parent_view_ setHidden:YES]; 122 [parent_view_ setHidden:YES];
124 bar_.reset( 123 bar_.reset(
125 [[BookmarkBarController alloc] initWithBrowser:helper_.browser() 124 [[BookmarkBarControllerNoOpen alloc]
126 initialWidth:NSWidth(parent_frame) 125 initWithBrowser:helper_.browser()
127 compressDelegate:compressDelegate_.get() 126 initialWidth:NSWidth(parent_frame)
128 resizeDelegate:resizeDelegate_.get() 127 compressDelegate:compressDelegate_.get()
129 urlDelegate:nil]); 128 resizeDelegate:resizeDelegate_.get()]);
130 129
131 InstallAndToggleBar(bar_.get()); 130 InstallAndToggleBar(bar_.get());
132 131
133 // Create a menu/item to act like a sender 132 // Create a menu/item to act like a sender
134 menu_.reset([[NSMenu alloc] initWithTitle:@"I_dont_care"]); 133 menu_.reset([[NSMenu alloc] initWithTitle:@"I_dont_care"]);
135 menu_item_.reset([[NSMenuItem alloc] 134 menu_item_.reset([[NSMenuItem alloc]
136 initWithTitle:@"still_dont_care" 135 initWithTitle:@"still_dont_care"
137 action:NULL 136 action:NULL
138 keyEquivalent:@""]); 137 keyEquivalent:@""]);
139 cell_.reset([[NSButtonCell alloc] init]); 138 cell_.reset([[NSButtonCell alloc] init]);
(...skipping 26 matching lines...)
166 [cell_ setRepresentedObject:[NSValue valueWithPointer:node]]; 165 [cell_ setRepresentedObject:[NSValue valueWithPointer:node]];
167 return menu_item_; 166 return menu_item_;
168 } 167 }
169 168
170 169
171 CocoaTestHelper cocoa_helper_; // Inits Cocoa, creates window, etc... 170 CocoaTestHelper cocoa_helper_; // Inits Cocoa, creates window, etc...
172 scoped_nsobject<NSView> parent_view_; 171 scoped_nsobject<NSView> parent_view_;
173 BrowserTestHelper helper_; 172 BrowserTestHelper helper_;
174 scoped_nsobject<ViewResizerPong> resizeDelegate_; 173 scoped_nsobject<ViewResizerPong> resizeDelegate_;
175 scoped_nsobject<CompressablePong> compressDelegate_; 174 scoped_nsobject<CompressablePong> compressDelegate_;
176 scoped_nsobject<BookmarkBarController> bar_; 175 scoped_nsobject<BookmarkBarControllerNoOpen> bar_;
177 scoped_nsobject<NSMenu> menu_; 176 scoped_nsobject<NSMenu> menu_;
178 scoped_nsobject<NSMenuItem> menu_item_; 177 scoped_nsobject<NSMenuItem> menu_item_;
179 scoped_nsobject<NSButtonCell> cell_; 178 scoped_nsobject<NSButtonCell> cell_;
180 scoped_ptr<BookmarkNode> node_; 179 scoped_ptr<BookmarkNode> node_;
181 }; 180 };
182 181
183 TEST_F(BookmarkBarControllerTest, ShowWhenShowBookmarkBarTrue) { 182 TEST_F(BookmarkBarControllerTest, ShowWhenShowBookmarkBarTrue) {
184 helper_.profile()->GetPrefs()->SetBoolean(prefs::kShowBookmarkBar, true); 183 helper_.profile()->GetPrefs()->SetBoolean(prefs::kShowBookmarkBar, true);
185 [bar_ updateVisibility]; 184 [bar_ updateVisibility];
186 185
(...skipping 26 matching lines...)
213 212
214 TEST_F(BookmarkBarControllerTest, ShowOnNewTabPage) { 213 TEST_F(BookmarkBarControllerTest, ShowOnNewTabPage) {
215 helper_.profile()->GetPrefs()->SetBoolean(prefs::kShowBookmarkBar, false); 214 helper_.profile()->GetPrefs()->SetBoolean(prefs::kShowBookmarkBar, false);
216 215
217 scoped_nsobject<BookmarkBarControllerTogglePong> bar; 216 scoped_nsobject<BookmarkBarControllerTogglePong> bar;
218 bar.reset( 217 bar.reset(
219 [[AlwaysNewTabPageBookmarkBarController alloc] 218 [[AlwaysNewTabPageBookmarkBarController alloc]
220 initWithBrowser:helper_.browser() 219 initWithBrowser:helper_.browser()
221 initialWidth:800 // arbitrary 220 initialWidth:800 // arbitrary
222 compressDelegate:compressDelegate_.get() 221 compressDelegate:compressDelegate_.get()
223 resizeDelegate:resizeDelegate_.get() 222 resizeDelegate:resizeDelegate_.get()]);
224 urlDelegate:nil]);
225 InstallAndToggleBar(bar.get()); 223 InstallAndToggleBar(bar.get());
226 224
227 [bar setBookmarkBarEnabled:NO]; 225 [bar setBookmarkBarEnabled:NO];
228 [bar updateVisibility]; 226 [bar updateVisibility];
229 227
230 EXPECT_TRUE([bar isVisible]); 228 EXPECT_TRUE([bar isVisible]);
231 EXPECT_FALSE([[bar view] isHidden]); 229 EXPECT_FALSE([[bar view] isHidden]);
232 EXPECT_GT([resizeDelegate_ height], 0); 230 EXPECT_GT([resizeDelegate_ height], 0);
233 EXPECT_GT([[bar view] frame].size.height, 0); 231 EXPECT_GT([[bar view] frame].size.height, 0);
234 232
(...skipping 25 matching lines...)
260 } 258 }
261 259
262 // Make sure we're watching for frame change notifications. 260 // Make sure we're watching for frame change notifications.
263 TEST_F(BookmarkBarControllerTest, FrameChangeNotification) { 261 TEST_F(BookmarkBarControllerTest, FrameChangeNotification) {
264 scoped_nsobject<BookmarkBarControllerTogglePong> bar; 262 scoped_nsobject<BookmarkBarControllerTogglePong> bar;
265 bar.reset( 263 bar.reset(
266 [[BookmarkBarControllerTogglePong alloc] 264 [[BookmarkBarControllerTogglePong alloc]
267 initWithBrowser:helper_.browser() 265 initWithBrowser:helper_.browser()
268 initialWidth:100 // arbitrary 266 initialWidth:100 // arbitrary
269 compressDelegate:compressDelegate_.get() 267 compressDelegate:compressDelegate_.get()
270 resizeDelegate:resizeDelegate_.get() 268 resizeDelegate:resizeDelegate_.get()]);
271 urlDelegate:nil]);
272 InstallAndToggleBar(bar.get()); 269 InstallAndToggleBar(bar.get());
273 270
274 // Send a frame did change notification for the pong's view. 271 // Send a frame did change notification for the pong's view.
275 [[NSNotificationCenter defaultCenter] 272 [[NSNotificationCenter defaultCenter]
276 postNotificationName:NSViewFrameDidChangeNotification 273 postNotificationName:NSViewFrameDidChangeNotification
277 object:[bar view]]; 274 object:[bar view]];
278 275
279 EXPECT_GT([bar toggles], 0); 276 EXPECT_GT([bar toggles], 0);
280 } 277 }
281 278
(...skipping 82 matching lines...)
364 EXPECT_TRUE(submenu); 361 EXPECT_TRUE(submenu);
365 EXPECT_EQ(2, [submenu numberOfItems]); 362 EXPECT_EQ(2, [submenu numberOfItems]);
366 EXPECT_TRUE([submenu itemWithTitle:@"f1"]); 363 EXPECT_TRUE([submenu itemWithTitle:@"f1"]);
367 EXPECT_TRUE([submenu itemWithTitle:@"f2"]); 364 EXPECT_TRUE([submenu itemWithTitle:@"f2"]);
368 } 365 }
369 366
370 // Confirm openBookmark: forwards the request to the controller's delegate 367 // Confirm openBookmark: forwards the request to the controller's delegate
371 TEST_F(BookmarkBarControllerTest, OpenBookmark) { 368 TEST_F(BookmarkBarControllerTest, OpenBookmark) {
372 GURL gurl("http://walla.walla.ding.dong.com"); 369 GURL gurl("http://walla.walla.ding.dong.com");
373 scoped_ptr<BookmarkNode> node(new BookmarkNode(gurl)); 370 scoped_ptr<BookmarkNode> node(new BookmarkNode(gurl));
374 scoped_nsobject<BookmarkURLOpenerPong> pong([[BookmarkURLOpenerPong alloc]
375 init]);
376 [bar_ setUrlDelegate:pong.get()];
377 371
378 scoped_nsobject<NSButtonCell> cell([[NSButtonCell alloc] init]); 372 scoped_nsobject<NSButtonCell> cell([[NSButtonCell alloc] init]);
379 scoped_nsobject<NSButton> button([[NSButton alloc] init]); 373 scoped_nsobject<NSButton> button([[NSButton alloc] init]);
380 [button setCell:cell.get()]; 374 [button setCell:cell.get()];
381 [cell setRepresentedObject:[NSValue valueWithPointer:node.get()]]; 375 [cell setRepresentedObject:[NSValue valueWithPointer:node.get()]];
382 376
383 [bar_ openBookmark:button]; 377 [bar_ openBookmark:button];
384 EXPECT_EQ(pong.get()->urls_[0], node->GetURL()); 378 EXPECT_EQ(bar_.get()->urls_[0], node->GetURL());
385 EXPECT_EQ(pong.get()->dispositions_[0], CURRENT_TAB); 379 EXPECT_EQ(bar_.get()->dispositions_[0], CURRENT_TAB);
386
387 [bar_ setUrlDelegate:nil];
388 } 380 }
389 381
390 // Confirm opening of bookmarks works from the menus (different 382 // Confirm opening of bookmarks works from the menus (different
391 // dispositions than clicking on the button). 383 // dispositions than clicking on the button).
392 TEST_F(BookmarkBarControllerTest, OpenBookmarkFromMenus) { 384 TEST_F(BookmarkBarControllerTest, OpenBookmarkFromMenus) {
393 scoped_nsobject<BookmarkURLOpenerPong> pong([[BookmarkURLOpenerPong alloc]
394 init]);
395 [bar_ setUrlDelegate:pong.get()];
396
397 const char* urls[] = { "http://walla.walla.ding.dong.com", 385 const char* urls[] = { "http://walla.walla.ding.dong.com",
398 "http://i_dont_know.com", 386 "http://i_dont_know.com",
399 "http://cee.enn.enn.dot.com" }; 387 "http://cee.enn.enn.dot.com" };
400 SEL selectors[] = { @selector(openBookmarkInNewForegroundTab:), 388 SEL selectors[] = { @selector(openBookmarkInNewForegroundTab:),
401 @selector(openBookmarkInNewWindow:), 389 @selector(openBookmarkInNewWindow:),
402 @selector(openBookmarkInIncognitoWindow:) }; 390 @selector(openBookmarkInIncognitoWindow:) };
403 WindowOpenDisposition dispositions[] = { NEW_FOREGROUND_TAB, 391 WindowOpenDisposition dispositions[] = { NEW_FOREGROUND_TAB,
404 NEW_WINDOW, 392 NEW_WINDOW,
405 OFF_THE_RECORD }; 393 OFF_THE_RECORD };
406 for (unsigned int i = 0; 394 for (unsigned int i = 0;
407 i < sizeof(dispositions)/sizeof(dispositions[0]); 395 i < sizeof(dispositions)/sizeof(dispositions[0]);
408 i++) { 396 i++) {
409 GURL gurl(urls[i]); 397 GURL gurl(urls[i]);
410 [bar_ performSelector:selectors[i] 398 [bar_ performSelector:selectors[i]
411 withObject:ItemForBookmarkBarMenu(gurl)]; 399 withObject:ItemForBookmarkBarMenu(gurl)];
412 EXPECT_EQ(pong.get()->urls_[0], gurl); 400 EXPECT_EQ(bar_.get()->urls_[0], gurl);
413 EXPECT_EQ(pong.get()->dispositions_[0], dispositions[i]); 401 EXPECT_EQ(bar_.get()->dispositions_[0], dispositions[i]);
414 [pong clear]; 402 [bar_ clear];
415 } 403 }
416 [bar_ setUrlDelegate:nil];
417 } 404 }
418 405
419 TEST_F(BookmarkBarControllerTest, TestAddRemoveAndClear) { 406 TEST_F(BookmarkBarControllerTest, TestAddRemoveAndClear) {
420 BookmarkModel* model = helper_.profile()->GetBookmarkModel(); 407 BookmarkModel* model = helper_.profile()->GetBookmarkModel();
421 NSView* buttonView = [bar_ buttonView]; 408 NSView* buttonView = [bar_ buttonView];
422 EXPECT_EQ(0U, [[bar_ buttons] count]); 409 EXPECT_EQ(0U, [[bar_ buttons] count]);
423 unsigned int initial_subview_count = [[buttonView subviews] count]; 410 unsigned int initial_subview_count = [[buttonView subviews] count];
424 411
425 // Make sure a redundant call doesn't choke 412 // Make sure a redundant call doesn't choke
426 [bar_ clearBookmarkBar]; 413 [bar_ clearBookmarkBar];
(...skipping 101 matching lines...)
528 515
529 NSMenuItem* item = ItemForBookmarkBarMenu(middle_node); 516 NSMenuItem* item = ItemForBookmarkBarMenu(middle_node);
530 [bar_ deleteBookmark:item]; 517 [bar_ deleteBookmark:item];
531 EXPECT_EQ(2, parent->GetChildCount()); 518 EXPECT_EQ(2, parent->GetChildCount());
532 EXPECT_EQ(parent->GetChild(0)->GetURL(), GURL(urls[0])); 519 EXPECT_EQ(parent->GetChild(0)->GetURL(), GURL(urls[0]));
533 // node 2 moved into spot 1 520 // node 2 moved into spot 1
534 EXPECT_EQ(parent->GetChild(1)->GetURL(), GURL(urls[2])); 521 EXPECT_EQ(parent->GetChild(1)->GetURL(), GURL(urls[2]));
535 } 522 }
536 523
537 TEST_F(BookmarkBarControllerTest, OpenAllBookmarks) { 524 TEST_F(BookmarkBarControllerTest, OpenAllBookmarks) {
538 scoped_nsobject<BookmarkURLOpenerPong> pong([[BookmarkURLOpenerPong alloc]
539 init]);
540 [bar_ setUrlDelegate:pong.get()];
541
542 BookmarkModel* model = helper_.profile()->GetBookmarkModel(); 525 BookmarkModel* model = helper_.profile()->GetBookmarkModel();
543 const BookmarkNode* parent = model->GetBookmarkBarNode(); 526 const BookmarkNode* parent = model->GetBookmarkBarNode();
544 // { one, { two-one, two-two }, three } 527 // { one, { two-one, two-two }, three }
545 model->AddURL(parent, parent->GetChildCount(), 528 model->AddURL(parent, parent->GetChildCount(),
546 L"title", GURL("http://one.com")); 529 L"title", GURL("http://one.com"));
547 const BookmarkNode* folder = model->AddGroup(parent, 530 const BookmarkNode* folder = model->AddGroup(parent,
548 parent->GetChildCount(), 531 parent->GetChildCount(),
549 L"group"); 532 L"group");
550 model->AddURL(folder, folder->GetChildCount(), 533 model->AddURL(folder, folder->GetChildCount(),
551 L"title", GURL("http://two-one.com")); 534 L"title", GURL("http://two-one.com"));
552 model->AddURL(folder, folder->GetChildCount(), 535 model->AddURL(folder, folder->GetChildCount(),
553 L"title", GURL("http://two-two.com")); 536 L"title", GURL("http://two-two.com"));
554 model->AddURL(parent, parent->GetChildCount(), 537 model->AddURL(parent, parent->GetChildCount(),
555 L"title", GURL("https://three.com")); 538 L"title", GURL("https://three.com"));
556 [bar_ openAllBookmarks:nil]; 539 [bar_ openAllBookmarks:nil];
557 540
558 EXPECT_EQ(pong.get()->urls_.size(), 4U); 541 EXPECT_EQ(bar_.get()->urls_.size(), 4U);
559 EXPECT_EQ(pong.get()->dispositions_.size(), 4U); 542 EXPECT_EQ(bar_.get()->dispositions_.size(), 4U);
560 543
561 // I can't use EXPECT_EQ() here since the macro can't expand 544 // I can't use EXPECT_EQ() here since the macro can't expand
562 // properly (no way to print the value of an iterator). 545 // properly (no way to print the value of an iterator).
563 std::vector<GURL>::iterator i; 546 std::vector<GURL>::iterator i;
564 std::vector<GURL>::iterator begin = pong.get()->urls_.begin(); 547 std::vector<GURL>::iterator begin = bar_.get()->urls_.begin();
565 std::vector<GURL>::iterator end = pong.get()->urls_.end(); 548 std::vector<GURL>::iterator end = bar_.get()->urls_.end();
566 i = find(begin, end, GURL("http://two-one.com")); 549 i = find(begin, end, GURL("http://two-one.com"));
567 EXPECT_FALSE(i == end); 550 EXPECT_FALSE(i == end);
568 i = find(begin, end, GURL("https://three.com")); 551 i = find(begin, end, GURL("https://three.com"));
569 EXPECT_FALSE(i == end); 552 EXPECT_FALSE(i == end);
570 i = find(begin, end, GURL("https://will-not-be-found.com")); 553 i = find(begin, end, GURL("https://will-not-be-found.com"));
571 EXPECT_TRUE(i == end); 554 EXPECT_TRUE(i == end);
572 555
573 EXPECT_EQ(pong.get()->dispositions_[3], NEW_BACKGROUND_TAB); 556 EXPECT_EQ(bar_.get()->dispositions_[3], NEW_BACKGROUND_TAB);
574
575 [bar_ setUrlDelegate:nil];
576 } 557 }
577 558
578 // TODO(jrg): write a test to confirm that nodeFavIconLoaded calls 559 // TODO(jrg): write a test to confirm that nodeFavIconLoaded calls
579 // checkForBookmarkButtonGrowth:. 560 // checkForBookmarkButtonGrowth:.
580 561
581 TEST_F(BookmarkBarControllerTest, Cell) { 562 TEST_F(BookmarkBarControllerTest, Cell) {
582 BookmarkModel* model = helper_.profile()->GetBookmarkModel(); 563 BookmarkModel* model = helper_.profile()->GetBookmarkModel();
583 [bar_ loaded:model]; 564 [bar_ loaded:model];
584 565
585 const BookmarkNode* parent = model->GetBookmarkBarNode(); 566 const BookmarkNode* parent = model->GetBookmarkBarNode();
(...skipping 19 matching lines...)
605 TEST_F(BookmarkBarControllerTest, MiddleClick) { 586 TEST_F(BookmarkBarControllerTest, MiddleClick) {
606 BookmarkModel* model = helper_.profile()->GetBookmarkModel(); 587 BookmarkModel* model = helper_.profile()->GetBookmarkModel();
607 GURL gurl1("http://www.google.com/"); 588 GURL gurl1("http://www.google.com/");
608 std::wstring title1(L"x"); 589 std::wstring title1(L"x");
609 model->SetURLStarred(gurl1, title1, true); 590 model->SetURLStarred(gurl1, title1, true);
610 591
611 EXPECT_EQ(1U, [[bar_ buttons] count]); 592 EXPECT_EQ(1U, [[bar_ buttons] count]);
612 NSButton* first = [[bar_ buttons] objectAtIndex:0]; 593 NSButton* first = [[bar_ buttons] objectAtIndex:0];
613 EXPECT_TRUE(first); 594 EXPECT_TRUE(first);
614 595
615 scoped_nsobject<BookmarkURLOpenerPong> pong([[BookmarkURLOpenerPong alloc]
616 init]);
617 [bar_ setUrlDelegate:pong.get()];
618 [first otherMouseUp:test_event_utils::MakeMouseEvent(NSOtherMouseUp, 0)]; 596 [first otherMouseUp:test_event_utils::MakeMouseEvent(NSOtherMouseUp, 0)];
619 EXPECT_EQ(pong.get()->urls_.size(), 1U); 597 EXPECT_EQ(bar_.get()->urls_.size(), 1U);
620 [bar_ setUrlDelegate:nil];
621 } 598 }
622 599
623 TEST_F(BookmarkBarControllerTest, TestBuildOffTheSideMenu) { 600 TEST_F(BookmarkBarControllerTest, TestBuildOffTheSideMenu) {
624 BookmarkModel* model = helper_.profile()->GetBookmarkModel(); 601 BookmarkModel* model = helper_.profile()->GetBookmarkModel();
625 NSMenu* menu = [bar_ offTheSideMenu]; 602 NSMenu* menu = [bar_ offTheSideMenu];
626 ASSERT_TRUE(menu); 603 ASSERT_TRUE(menu);
627 604
628 // The bookmark bar should start out with nothing. 605 // The bookmark bar should start out with nothing.
629 EXPECT_EQ(0U, [[bar_ buttons] count]); 606 EXPECT_EQ(0U, [[bar_ buttons] count]);
630 607
(...skipping 93 matching lines...)
724 const BookmarkNode* parent = model->GetBookmarkBarNode(); 701 const BookmarkNode* parent = model->GetBookmarkBarNode();
725 [bar_ addURLs:nsurls withTitles:nstitles at:NSZeroPoint]; 702 [bar_ addURLs:nsurls withTitles:nstitles at:NSZeroPoint];
726 EXPECT_EQ(3, parent->GetChildCount()); 703 EXPECT_EQ(3, parent->GetChildCount());
727 for (int i = 0; i < parent->GetChildCount(); ++i) { 704 for (int i = 0; i < parent->GetChildCount(); ++i) {
728 EXPECT_EQ(parent->GetChild(i)->GetURL(), GURL(urls[i])); 705 EXPECT_EQ(parent->GetChild(i)->GetURL(), GURL(urls[i]));
729 EXPECT_EQ(parent->GetChild(i)->GetTitle(), titles[i]); 706 EXPECT_EQ(parent->GetChild(i)->GetTitle(), titles[i]);
730 } 707 }
731 } 708 }
732 709
733 } // namespace 710 } // namespace
OLDNEW
« no previous file with comments | « chrome/browser/cocoa/bookmark_bar_controller.mm ('k') | chrome/browser/cocoa/browser_window_controller.h » ('j') | no next file with comments »

Powered by Google App Engine