| OLD | NEW |
| 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 <Cocoa/Cocoa.h> | 5 #import <Cocoa/Cocoa.h> |
| 6 #include <stddef.h> | 6 #include <stddef.h> |
| 7 #include <stdint.h> | 7 #include <stdint.h> |
| 8 | 8 |
| 9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
| 10 #include "base/mac/mac_util.h" | 10 #include "base/mac/mac_util.h" |
| (...skipping 702 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 713 layout = [bar_ layoutFromCurrentState]; | 713 layout = [bar_ layoutFromCurrentState]; |
| 714 EXPECT_FALSE(layout.IsAppsButtonVisible()); | 714 EXPECT_FALSE(layout.IsAppsButtonVisible()); |
| 715 | 715 |
| 716 // And try showing it via policy too. | 716 // And try showing it via policy too. |
| 717 prefs->SetManagedPref(bookmarks::prefs::kShowAppsShortcutInBookmarkBar, | 717 prefs->SetManagedPref(bookmarks::prefs::kShowAppsShortcutInBookmarkBar, |
| 718 base::MakeUnique<base::Value>(true)); | 718 base::MakeUnique<base::Value>(true)); |
| 719 layout = [bar_ layoutFromCurrentState]; | 719 layout = [bar_ layoutFromCurrentState]; |
| 720 EXPECT_TRUE(layout.IsAppsButtonVisible()); | 720 EXPECT_TRUE(layout.IsAppsButtonVisible()); |
| 721 } | 721 } |
| 722 | 722 |
| 723 // This tests a formerly-pathological case where if there was a single |
| 724 // bookmark on the bar and it was renamed, the button wouldn't update |
| 725 // since the offset and number of buttons stayed the same. |
| 726 // See crbug.com/724201 |
| 727 TEST_F(BookmarkBarControllerTest, RenameBookmark) { |
| 728 BookmarkModel* model = BookmarkModelFactory::GetForBrowserContext(profile()); |
| 729 const BookmarkNode* barNode = model->bookmark_bar_node(); |
| 730 const BookmarkNode* node = model->AddURL(barNode, 0, ASCIIToUTF16("Lorem"), |
| 731 GURL("http://example.com")); |
| 732 EXPECT_EQ([[bar_ buttons] count], 1U); |
| 733 EXPECT_NSEQ([[[bar_ buttons] firstObject] title], @"Lorem"); |
| 734 |
| 735 model->SetTitle(node, ASCIIToUTF16("Ipsum")); |
| 736 [bar_ rebuildLayoutWithAnimated:NO]; |
| 737 EXPECT_EQ([[bar_ buttons] count], 1U); |
| 738 EXPECT_NSEQ([[[bar_ buttons] firstObject] title], @"Ipsum"); |
| 739 } |
| 740 |
| 723 TEST_F(BookmarkBarControllerTest, NoItemsResizing) { | 741 TEST_F(BookmarkBarControllerTest, NoItemsResizing) { |
| 724 bookmarks::BookmarkBarLayout layout = [bar_ layoutFromCurrentState]; | 742 bookmarks::BookmarkBarLayout layout = [bar_ layoutFromCurrentState]; |
| 725 EXPECT_TRUE(layout.IsNoItemTextFieldVisible() && | 743 EXPECT_TRUE(layout.IsNoItemTextFieldVisible() && |
| 726 layout.IsImportBookmarksButtonVisible()); | 744 layout.IsImportBookmarksButtonVisible()); |
| 727 CGFloat oldOffset = layout.import_bookmarks_button_offset; | 745 CGFloat oldOffset = layout.import_bookmarks_button_offset; |
| 728 CGFloat oldWidth = layout.import_bookmarks_button_width; | 746 CGFloat oldWidth = layout.import_bookmarks_button_width; |
| 729 CGRect viewFrame = [[bar_ view] frame]; | 747 CGRect viewFrame = [[bar_ view] frame]; |
| 730 CGFloat originalViewWidth = NSWidth(viewFrame); | 748 CGFloat originalViewWidth = NSWidth(viewFrame); |
| 731 // Assert that the import bookmarks button fits. | 749 // Assert that the import bookmarks button fits. |
| 732 EXPECT_GT(originalViewWidth, oldOffset + oldWidth); | 750 EXPECT_GT(originalViewWidth, oldOffset + oldWidth); |
| (...skipping 1443 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2176 "2f3b ] 4b "); | 2194 "2f3b ] 4b "); |
| 2177 actual = bookmarks::test::ModelStringFromNode(root); | 2195 actual = bookmarks::test::ModelStringFromNode(root); |
| 2178 EXPECT_EQ(expected, actual); | 2196 EXPECT_EQ(expected, actual); |
| 2179 | 2197 |
| 2180 // Verify that the other bookmark folder can't be deleted. | 2198 // Verify that the other bookmark folder can't be deleted. |
| 2181 BookmarkButton *otherButton = [bar_ otherBookmarksButton]; | 2199 BookmarkButton *otherButton = [bar_ otherBookmarksButton]; |
| 2182 EXPECT_FALSE([bar_ canDragBookmarkButtonToTrash:otherButton]); | 2200 EXPECT_FALSE([bar_ canDragBookmarkButtonToTrash:otherButton]); |
| 2183 } | 2201 } |
| 2184 | 2202 |
| 2185 } // namespace | 2203 } // namespace |
| OLD | NEW |