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

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

Issue 842005: Bookmark bar menu/folder button text is left-aligned, not centered.... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 10 years, 9 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 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 #import "chrome/browser/cocoa/bookmark_bar_controller.h" 9 #import "chrome/browser/cocoa/bookmark_bar_controller.h"
10 #import "chrome/browser/cocoa/bookmark_bar_folder_controller.h" 10 #import "chrome/browser/cocoa/bookmark_bar_folder_controller.h"
(...skipping 20 matching lines...) Expand all
31 31
32 - (void)childFolderWillClose:(id<BookmarkButtonControllerProtocol>)child { 32 - (void)childFolderWillClose:(id<BookmarkButtonControllerProtocol>)child {
33 childFolderWillClose_ = YES; 33 childFolderWillClose_ = YES;
34 } 34 }
35 @end 35 @end
36 36
37 class BookmarkBarFolderControllerTest : public CocoaTest { 37 class BookmarkBarFolderControllerTest : public CocoaTest {
38 public: 38 public:
39 BrowserTestHelper helper_; 39 BrowserTestHelper helper_;
40 scoped_nsobject<BookmarkBarController> parentBarController_; 40 scoped_nsobject<BookmarkBarController> parentBarController_;
41 const BookmarkNode* longTitleNode_; // owned by model
41 42
42 BookmarkBarFolderControllerTest() { 43 BookmarkBarFolderControllerTest() {
43 BookmarkModel* model = helper_.profile()->GetBookmarkModel(); 44 BookmarkModel* model = helper_.profile()->GetBookmarkModel();
44 const BookmarkNode* parent = model->GetBookmarkBarNode(); 45 const BookmarkNode* parent = model->GetBookmarkBarNode();
45 const BookmarkNode* folderA = model->AddGroup(parent, 46 const BookmarkNode* folderA = model->AddGroup(parent,
46 parent->GetChildCount(), 47 parent->GetChildCount(),
47 L"group"); 48 L"group");
48 model->AddGroup(parent, parent->GetChildCount(), 49 model->AddGroup(parent, parent->GetChildCount(),
49 L"sibbling group"); 50 L"sibbling group");
50 const BookmarkNode* folderB = model->AddGroup(folderA, 51 const BookmarkNode* folderB = model->AddGroup(folderA,
51 folderA->GetChildCount(), 52 folderA->GetChildCount(),
52 L"subgroup"); 53 L"subgroup");
53 model->AddURL(folderA, folderA->GetChildCount(), L"title a", 54 model->AddURL(folderA, folderA->GetChildCount(), L"title a",
54 GURL("http://www.google.com/a")); 55 GURL("http://www.google.com/a"));
55 model->AddURL(folderA, folderA->GetChildCount(), 56 longTitleNode_ = model->AddURL(
56 L"title super duper long long whoa momma title you betcha", 57 folderA, folderA->GetChildCount(),
57 GURL("http://www.google.com/b")); 58 L"title super duper long long whoa momma title you betcha",
59 GURL("http://www.google.com/b"));
58 model->AddURL(folderB, folderB->GetChildCount(), L"t", 60 model->AddURL(folderB, folderB->GetChildCount(), L"t",
59 GURL("http://www.google.com/c")); 61 GURL("http://www.google.com/c"));
60 62
61 parentBarController_.reset( 63 parentBarController_.reset(
62 [[BookmarkBarController alloc] 64 [[BookmarkBarController alloc]
63 initWithBrowser:helper_.browser() 65 initWithBrowser:helper_.browser()
64 initialWidth:300 66 initialWidth:300
65 delegate:nil 67 delegate:nil
66 resizeDelegate:nil]); 68 resizeDelegate:nil]);
67 [parentBarController_ loaded:model]; 69 [parentBarController_ loaded:model];
68 } 70 }
69 71
72 // Remove the bookmark with the long title.
73 void RemoveLongTitleNode() {
74 BookmarkModel* model = helper_.profile()->GetBookmarkModel();
75 model->Remove(longTitleNode_->GetParent(),
76 longTitleNode_->GetParent()->IndexOfChild(longTitleNode_));
77 }
78
70 // Return a simple BookmarkBarFolderController. 79 // Return a simple BookmarkBarFolderController.
71 BookmarkBarFolderController* SimpleBookmarkBarFolderController() { 80 BookmarkBarFolderController* SimpleBookmarkBarFolderController() {
72 BookmarkButton* parentButton = [[parentBarController_ buttons] 81 BookmarkButton* parentButton = [[parentBarController_ buttons]
73 objectAtIndex:0]; 82 objectAtIndex:0];
74 return [[BookmarkBarFolderControllerPong alloc] 83 return [[BookmarkBarFolderControllerPong alloc]
75 initWithParentButton:parentButton 84 initWithParentButton:parentButton
76 parentController:parentBarController_]; 85 parentController:parentBarController_];
77 } 86 }
78 87
79 }; 88 };
(...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after
224 233
225 EXPECT_FALSE([bbfc childFolderWillShow]); 234 EXPECT_FALSE([bbfc childFolderWillShow]);
226 [bbfc openBookmarkFolderFromButton:[[bbfc buttons] objectAtIndex:0]]; 235 [bbfc openBookmarkFolderFromButton:[[bbfc buttons] objectAtIndex:0]];
227 EXPECT_TRUE([bbfc childFolderWillShow]); 236 EXPECT_TRUE([bbfc childFolderWillShow]);
228 237
229 EXPECT_FALSE([bbfc childFolderWillClose]); 238 EXPECT_FALSE([bbfc childFolderWillClose]);
230 [bbfc closeBookmarkFolder:nil]; 239 [bbfc closeBookmarkFolder:nil];
231 EXPECT_TRUE([bbfc childFolderWillClose]); 240 EXPECT_TRUE([bbfc childFolderWillClose]);
232 } 241 }
233 242
243 // Make sure bookmark folders have variable widths.
244 TEST_F(BookmarkBarFolderControllerTest, ChildFolderWidth) {
245 scoped_nsobject<BookmarkBarFolderController> bbfc;
246
247 bbfc.reset(SimpleBookmarkBarFolderController());
248 EXPECT_TRUE(bbfc.get());
249 CGFloat wideWidth = NSWidth([[bbfc window] frame]);
250
251 RemoveLongTitleNode();
252 bbfc.reset(SimpleBookmarkBarFolderController());
253 EXPECT_TRUE(bbfc.get());
254 CGFloat thinWidth = NSWidth([[bbfc window] frame]);
255
256 // Make sure window size changed as expected.
257 EXPECT_GT(wideWidth, thinWidth);
258 }
259
260
261
234 // TODO(jrg): draggingEntered: and draggingExited: trigger timers so 262 // TODO(jrg): draggingEntered: and draggingExited: trigger timers so
235 // they are hard to test. Factor out "fire timers" into routines 263 // they are hard to test. Factor out "fire timers" into routines
236 // which can be overridden to fire immediately to make behavior 264 // which can be overridden to fire immediately to make behavior
237 // confirmable. 265 // confirmable.
238 // There is a similar problem with mouseEnteredButton: and 266 // There is a similar problem with mouseEnteredButton: and
239 // mouseExitedButton:. 267 // mouseExitedButton:.
OLDNEW
« no previous file with comments | « chrome/browser/cocoa/bookmark_bar_folder_controller.mm ('k') | chrome/browser/cocoa/bookmark_button_cell.mm » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698