Index: chrome/browser/cocoa/bookmark_bar_folder_controller_unittest.mm |
=================================================================== |
--- chrome/browser/cocoa/bookmark_bar_folder_controller_unittest.mm (revision 41344) |
+++ chrome/browser/cocoa/bookmark_bar_folder_controller_unittest.mm (working copy) |
@@ -38,6 +38,7 @@ |
public: |
BrowserTestHelper helper_; |
scoped_nsobject<BookmarkBarController> parentBarController_; |
+ const BookmarkNode* longTitleNode_; // owned by model |
BookmarkBarFolderControllerTest() { |
BookmarkModel* model = helper_.profile()->GetBookmarkModel(); |
@@ -52,9 +53,10 @@ |
L"subgroup"); |
model->AddURL(folderA, folderA->GetChildCount(), L"title a", |
GURL("http://www.google.com/a")); |
- model->AddURL(folderA, folderA->GetChildCount(), |
- L"title super duper long long whoa momma title you betcha", |
- GURL("http://www.google.com/b")); |
+ longTitleNode_ = model->AddURL( |
+ folderA, folderA->GetChildCount(), |
+ L"title super duper long long whoa momma title you betcha", |
+ GURL("http://www.google.com/b")); |
model->AddURL(folderB, folderB->GetChildCount(), L"t", |
GURL("http://www.google.com/c")); |
@@ -67,6 +69,13 @@ |
[parentBarController_ loaded:model]; |
} |
+ // Remove the bookmark with the long title. |
+ void RemoveLongTitleNode() { |
+ BookmarkModel* model = helper_.profile()->GetBookmarkModel(); |
+ model->Remove(longTitleNode_->GetParent(), |
+ longTitleNode_->GetParent()->IndexOfChild(longTitleNode_)); |
+ } |
+ |
// Return a simple BookmarkBarFolderController. |
BookmarkBarFolderController* SimpleBookmarkBarFolderController() { |
BookmarkButton* parentButton = [[parentBarController_ buttons] |
@@ -231,6 +240,25 @@ |
EXPECT_TRUE([bbfc childFolderWillClose]); |
} |
+// Make sure bookmark folders have variable widths. |
+TEST_F(BookmarkBarFolderControllerTest, ChildFolderWidth) { |
+ scoped_nsobject<BookmarkBarFolderController> bbfc; |
+ |
+ bbfc.reset(SimpleBookmarkBarFolderController()); |
+ EXPECT_TRUE(bbfc.get()); |
+ CGFloat wideWidth = NSWidth([[bbfc window] frame]); |
+ |
+ RemoveLongTitleNode(); |
+ bbfc.reset(SimpleBookmarkBarFolderController()); |
+ EXPECT_TRUE(bbfc.get()); |
+ CGFloat thinWidth = NSWidth([[bbfc window] frame]); |
+ |
+ // Make sure window size changed as expected. |
+ EXPECT_GT(wideWidth, thinWidth); |
+} |
+ |
+ |
+ |
// TODO(jrg): draggingEntered: and draggingExited: trigger timers so |
// they are hard to test. Factor out "fire timers" into routines |
// which can be overridden to fire immediately to make behavior |