| 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 #include <cmath> | 5 #include <cmath> |
| 6 | 6 |
| 7 #include "base/mac/scoped_nsobject.h" | 7 #include "base/mac/scoped_nsobject.h" |
| 8 #include "base/strings/utf_string_conversions.h" | 8 #include "base/strings/utf_string_conversions.h" |
| 9 #include "chrome/browser/bookmarks/bookmark_model_factory.h" | 9 #include "chrome/browser/bookmarks/bookmark_model_factory.h" |
| 10 #import "chrome/browser/ui/cocoa/bookmarks/bookmark_bar_constants.h" | 10 #import "chrome/browser/ui/cocoa/bookmarks/bookmark_bar_constants.h" |
| (...skipping 1597 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1608 CGFloat pos = [folder indicatorPosForDragToPoint:targetPoint]; | 1608 CGFloat pos = [folder indicatorPosForDragToPoint:targetPoint]; |
| 1609 EXPECT_CGFLOAT_EQ(targetPoint.y + yTopOffset, pos); | 1609 EXPECT_CGFLOAT_EQ(targetPoint.y + yTopOffset, pos); |
| 1610 pos = [folder indicatorPosForDragToPoint:[targetButton bottom]]; | 1610 pos = [folder indicatorPosForDragToPoint:[targetButton bottom]]; |
| 1611 targetButton = [folder buttonWithTitleEqualTo:@"2f2f"]; | 1611 targetButton = [folder buttonWithTitleEqualTo:@"2f2f"]; |
| 1612 EXPECT_CGFLOAT_EQ([targetButton top].y + yTopOffset, pos); | 1612 EXPECT_CGFLOAT_EQ([targetButton top].y + yTopOffset, pos); |
| 1613 pos = [folder indicatorPosForDragToPoint:NSMakePoint(10,0)]; | 1613 pos = [folder indicatorPosForDragToPoint:NSMakePoint(10,0)]; |
| 1614 targetButton = [folder buttonWithTitleEqualTo:@"2f3b"]; | 1614 targetButton = [folder buttonWithTitleEqualTo:@"2f3b"]; |
| 1615 EXPECT_CGFLOAT_EQ([targetButton bottom].y - yBottomOffset, pos); | 1615 EXPECT_CGFLOAT_EQ([targetButton bottom].y - yBottomOffset, pos); |
| 1616 } | 1616 } |
| 1617 | 1617 |
| 1618 TEST_F(BookmarkBarFolderControllerMenuTest, FolderTooltips) { |
| 1619 BookmarkModel* model = BookmarkModelFactory::GetForBrowserContext(profile()); |
| 1620 const BookmarkNode* otherBookmarks = model->other_node(); |
| 1621 model->AddFolder(otherBookmarks, otherBookmarks->child_count(), |
| 1622 ASCIIToUTF16("short_name")); |
| 1623 model->AddFolder( |
| 1624 otherBookmarks, otherBookmarks->child_count(), |
| 1625 ASCIIToUTF16("reallyReallyLongBookmarkNamereallyReallyLongBookmarkNamerea" |
| 1626 "llyReallyLongBookmarkNamereallyReallyLongBookmarkName")); |
| 1627 BookmarkButton* otherButton = [bar_ otherBookmarksButton]; |
| 1628 ASSERT_TRUE(otherButton); |
| 1629 |
| 1630 [[otherButton target] openBookmarkFolderFromButton:otherButton]; |
| 1631 BookmarkBarFolderController* folder = [bar_ folderController]; |
| 1632 EXPECT_TRUE(folder); |
| 1633 |
| 1634 NSArray* buttons = [folder buttons]; |
| 1635 EXPECT_EQ(2U, [buttons count]); |
| 1636 |
| 1637 for (BookmarkButton* btn in buttons) { |
| 1638 if ([[btn cell] cellSize].width > |
| 1639 bookmarks::kBookmarkMenuButtonMaximumWidth) { |
| 1640 EXPECT_TRUE([btn toolTip]); |
| 1641 } else { |
| 1642 EXPECT_FALSE([btn toolTip]); |
| 1643 } |
| 1644 } |
| 1645 } |
| 1646 |
| 1618 @interface BookmarkBarControllerNoDelete : BookmarkBarController | 1647 @interface BookmarkBarControllerNoDelete : BookmarkBarController |
| 1619 - (IBAction)deleteBookmark:(id)sender; | 1648 - (IBAction)deleteBookmark:(id)sender; |
| 1620 @end | 1649 @end |
| 1621 | 1650 |
| 1622 @implementation BookmarkBarControllerNoDelete | 1651 @implementation BookmarkBarControllerNoDelete |
| 1623 - (IBAction)deleteBookmark:(id)sender { | 1652 - (IBAction)deleteBookmark:(id)sender { |
| 1624 // NOP | 1653 // NOP |
| 1625 } | 1654 } |
| 1626 @end | 1655 @end |
| 1627 | 1656 |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1670 DeleteBookmark([folder parentButton], profile()); | 1699 DeleteBookmark([folder parentButton], profile()); |
| 1671 EXPECT_FALSE([folder folderController]); | 1700 EXPECT_FALSE([folder folderController]); |
| 1672 } | 1701 } |
| 1673 | 1702 |
| 1674 // TODO(jrg): draggingEntered: and draggingExited: trigger timers so | 1703 // TODO(jrg): draggingEntered: and draggingExited: trigger timers so |
| 1675 // they are hard to test. Factor out "fire timers" into routines | 1704 // they are hard to test. Factor out "fire timers" into routines |
| 1676 // which can be overridden to fire immediately to make behavior | 1705 // which can be overridden to fire immediately to make behavior |
| 1677 // confirmable. | 1706 // confirmable. |
| 1678 // There is a similar problem with mouseEnteredButton: and | 1707 // There is a similar problem with mouseEnteredButton: and |
| 1679 // mouseExitedButton:. | 1708 // mouseExitedButton:. |
| OLD | NEW |