| 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 | 6 |
| 7 #include "base/basictypes.h" | 7 #include "base/basictypes.h" |
| 8 #include "base/command_line.h" | 8 #include "base/command_line.h" |
| 9 #include "base/mac/mac_util.h" |
| 9 #include "base/mac/scoped_nsobject.h" | 10 #include "base/mac/scoped_nsobject.h" |
| 10 #include "base/strings/string16.h" | 11 #include "base/strings/string16.h" |
| 11 #include "base/strings/string_util.h" | 12 #include "base/strings/string_util.h" |
| 12 #include "base/strings/sys_string_conversions.h" | 13 #include "base/strings/sys_string_conversions.h" |
| 13 #include "base/strings/utf_string_conversions.h" | 14 #include "base/strings/utf_string_conversions.h" |
| 14 #include "chrome/browser/bookmarks/bookmark_model_factory.h" | 15 #include "chrome/browser/bookmarks/bookmark_model_factory.h" |
| 15 #include "chrome/browser/extensions/test_extension_system.h" | 16 #include "chrome/browser/extensions/test_extension_system.h" |
| 16 #import "chrome/browser/ui/cocoa/bookmarks/bookmark_bar_constants.h" | 17 #import "chrome/browser/ui/cocoa/bookmarks/bookmark_bar_constants.h" |
| 17 #import "chrome/browser/ui/cocoa/bookmarks/bookmark_bar_controller.h" | 18 #import "chrome/browser/ui/cocoa/bookmarks/bookmark_bar_controller.h" |
| 18 #import "chrome/browser/ui/cocoa/bookmarks/bookmark_bar_folder_window.h" | 19 #import "chrome/browser/ui/cocoa/bookmarks/bookmark_bar_folder_window.h" |
| (...skipping 1550 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1569 profile()->GetPrefs()->SetBoolean( | 1570 profile()->GetPrefs()->SetBoolean( |
| 1570 bookmarks::prefs::kShowAppsShortcutInBookmarkBar, false); | 1571 bookmarks::prefs::kShowAppsShortcutInBookmarkBar, false); |
| 1571 ASSERT_TRUE([bar_ appsPageShortcutButtonIsHidden]); | 1572 ASSERT_TRUE([bar_ appsPageShortcutButtonIsHidden]); |
| 1572 | 1573 |
| 1573 BookmarkModel* model = BookmarkModelFactory::GetForProfile(profile()); | 1574 BookmarkModel* model = BookmarkModelFactory::GetForProfile(profile()); |
| 1574 const BookmarkNode* root = model->bookmark_bar_node(); | 1575 const BookmarkNode* root = model->bookmark_bar_node(); |
| 1575 const std::string model_string("1b 2f:[ 2f1b 2f2b ] 3b "); | 1576 const std::string model_string("1b 2f:[ 2f1b 2f2b ] 3b "); |
| 1576 test::AddNodesFromModelString(model, root, model_string); | 1577 test::AddNodesFromModelString(model, root, model_string); |
| 1577 [bar_ frameDidChange]; | 1578 [bar_ frameDidChange]; |
| 1578 | 1579 |
| 1579 CGFloat viewWidths[] = { 123.0, 124.0, 151.0, 152.0, 153.0, 154.0, 155.0, | 1580 // The default font changed between OSX Mavericks and OSX Yosemite, so this |
| 1580 200.0, 155.0, 154.0, 153.0, 152.0, 151.0, 124.0, | 1581 // test requires different widths to trigger the appropriate results. |
| 1581 123.0 }; | 1582 CGFloat viewWidthsYosemite[] = { 121.0, 122.0, 148.0, 149.0, 150.0, 151.0, |
| 1583 152.0, 200.0, 152.0, 151.0, 150.0, 149.0, |
| 1584 148.0, 122.0, 121.0 }; |
| 1585 CGFloat viewWidthsMavericks[] = { 123.0, 124.0, 151.0, 152.0, 153.0, 154.0, |
| 1586 155.0, 200.0, 155.0, 154.0, 153.0, 152.0, |
| 1587 151.0, 124.0, 123.0 }; |
| 1582 BOOL offTheSideButtonIsHiddenResults[] = { NO, NO, NO, NO, YES, YES, YES, YES, | 1588 BOOL offTheSideButtonIsHiddenResults[] = { NO, NO, NO, NO, YES, YES, YES, YES, |
| 1583 YES, YES, YES, NO, NO, NO, NO}; | 1589 YES, YES, YES, NO, NO, NO, NO}; |
| 1584 int displayedButtonCountResults[] = { 1, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 2, 2, | 1590 int displayedButtonCountResults[] = { 1, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 2, 2, |
| 1585 2, 1 }; | 1591 2, 1 }; |
| 1592 CGFloat* viewWidths = base::mac::IsOSYosemiteOrLater() ? viewWidthsYosemite |
| 1593 : viewWidthsMavericks; |
| 1586 | 1594 |
| 1587 for (unsigned int i = 0; i < sizeof(viewWidths) / sizeof(viewWidths[0]); | 1595 for (unsigned int i = 0; i < arraysize(viewWidthsYosemite); ++i) { |
| 1588 ++i) { | |
| 1589 NSRect frame = [[bar_ view] frame]; | 1596 NSRect frame = [[bar_ view] frame]; |
| 1590 frame.size.width = viewWidths[i] + bookmarks::kBookmarkRightMargin; | 1597 frame.size.width = viewWidths[i] + bookmarks::kBookmarkRightMargin; |
| 1591 [[bar_ view] setFrame:frame]; | 1598 [[bar_ view] setFrame:frame]; |
| 1592 EXPECT_EQ(offTheSideButtonIsHiddenResults[i], | 1599 EXPECT_EQ(offTheSideButtonIsHiddenResults[i], |
| 1593 [bar_ offTheSideButtonIsHidden]); | 1600 [bar_ offTheSideButtonIsHidden]); |
| 1594 EXPECT_EQ(displayedButtonCountResults[i], [bar_ displayedButtonCount]); | 1601 EXPECT_EQ(displayedButtonCountResults[i], [bar_ displayedButtonCount]); |
| 1595 } | 1602 } |
| 1596 } | 1603 } |
| 1597 | 1604 |
| 1598 TEST_F(BookmarkBarControllerTest, BookmarksWithAppsPageShortcut) { | 1605 TEST_F(BookmarkBarControllerTest, BookmarksWithAppsPageShortcut) { |
| (...skipping 530 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2129 "2f3b ] 4b "); | 2136 "2f3b ] 4b "); |
| 2130 actual = test::ModelStringFromNode(root); | 2137 actual = test::ModelStringFromNode(root); |
| 2131 EXPECT_EQ(expected, actual); | 2138 EXPECT_EQ(expected, actual); |
| 2132 | 2139 |
| 2133 // Verify that the other bookmark folder can't be deleted. | 2140 // Verify that the other bookmark folder can't be deleted. |
| 2134 BookmarkButton *otherButton = [bar_ otherBookmarksButton]; | 2141 BookmarkButton *otherButton = [bar_ otherBookmarksButton]; |
| 2135 EXPECT_FALSE([bar_ canDragBookmarkButtonToTrash:otherButton]); | 2142 EXPECT_FALSE([bar_ canDragBookmarkButtonToTrash:otherButton]); |
| 2136 } | 2143 } |
| 2137 | 2144 |
| 2138 } // namespace | 2145 } // namespace |
| OLD | NEW |