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

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

Issue 1986963004: Revert of [Mac][Material Design] Update bookmarks bar to Material Design. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 7 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
OLDNEW
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 603 matching lines...) Expand 10 before | Expand all | Expand 10 after
614 BookmarkButton* button = [buttons objectAtIndex:3]; 614 BookmarkButton* button = [buttons objectAtIndex:3];
615 DeleteBookmark(button, profile()); 615 DeleteBookmark(button, profile());
616 CGFloat newTop = [menuWindow frame].origin.y + NSHeight([menuWindow frame]); 616 CGFloat newTop = [menuWindow frame].origin.y + NSHeight([menuWindow frame]);
617 EXPECT_CGFLOAT_EQ(oldTop, newTop); 617 EXPECT_CGFLOAT_EQ(oldTop, newTop);
618 618
619 // Scroll so that both the top and bottom scroll arrows show, make sure 619 // Scroll so that both the top and bottom scroll arrows show, make sure
620 // the top of the window has moved up, then delete a visible button and 620 // the top of the window has moved up, then delete a visible button and
621 // make sure the top has not moved. 621 // make sure the top has not moved.
622 oldTop = newTop; 622 oldTop = newTop;
623 const CGFloat scrollOneBookmark = bookmarks::kBookmarkFolderButtonHeight + 623 const CGFloat scrollOneBookmark = bookmarks::kBookmarkFolderButtonHeight +
624 bookmarks::BookmarkVerticalPadding(); 624 bookmarks::kBookmarkVerticalPadding;
625 NSUInteger buttonCounter = 0; 625 NSUInteger buttonCounter = 0;
626 NSUInteger extraButtonLimit = 3; 626 NSUInteger extraButtonLimit = 3;
627 while (![bbfc canScrollDown] || extraButtonLimit > 0) { 627 while (![bbfc canScrollDown] || extraButtonLimit > 0) {
628 [bbfc performOneScroll:scrollOneBookmark updateMouseSelection:NO]; 628 [bbfc performOneScroll:scrollOneBookmark updateMouseSelection:NO];
629 ++buttonCounter; 629 ++buttonCounter;
630 if ([bbfc canScrollDown]) 630 if ([bbfc canScrollDown])
631 --extraButtonLimit; 631 --extraButtonLimit;
632 } 632 }
633 newTop = [menuWindow frame].origin.y + NSHeight([menuWindow frame]); 633 newTop = [menuWindow frame].origin.y + NSHeight([menuWindow frame]);
634 EXPECT_NE(oldTop, newTop); 634 EXPECT_NE(oldTop, newTop);
(...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after
766 BookmarkBarFolderController* folderController = [bar_ folderController]; 766 BookmarkBarFolderController* folderController = [bar_ folderController];
767 EXPECT_TRUE(folderController); 767 EXPECT_TRUE(folderController);
768 NSWindow* toWindow = [folderController window]; 768 NSWindow* toWindow = [folderController window];
769 EXPECT_TRUE(toWindow); 769 EXPECT_TRUE(toWindow);
770 NSRect oldToWindowFrame = [toWindow frame]; 770 NSRect oldToWindowFrame = [toWindow frame];
771 // Drag a bar button onto a bookmark (i.e. not a folder) in a folder 771 // Drag a bar button onto a bookmark (i.e. not a folder) in a folder
772 // so it should end up below the target bookmark. 772 // so it should end up below the target bookmark.
773 BookmarkButton* draggedButton = [bar_ buttonWithTitleEqualTo:@"1b"]; 773 BookmarkButton* draggedButton = [bar_ buttonWithTitleEqualTo:@"1b"];
774 ASSERT_TRUE(draggedButton); 774 ASSERT_TRUE(draggedButton);
775 CGFloat horizontalShift = 775 CGFloat horizontalShift =
776 NSWidth([draggedButton frame]) + bookmarks::BookmarkHorizontalPadding(); 776 NSWidth([draggedButton frame]) + bookmarks::kBookmarkHorizontalPadding;
777 BookmarkButton* targetButton = 777 BookmarkButton* targetButton =
778 [folderController buttonWithTitleEqualTo:@"2f1b"]; 778 [folderController buttonWithTitleEqualTo:@"2f1b"];
779 ASSERT_TRUE(targetButton); 779 ASSERT_TRUE(targetButton);
780 [folderController dragButton:draggedButton 780 [folderController dragButton:draggedButton
781 to:[targetButton center] 781 to:[targetButton center]
782 copy:NO]; 782 copy:NO];
783 // The button should have landed just after "2f1b". 783 // The button should have landed just after "2f1b".
784 const std::string expected_string("2f:[ 2f1b 1b 2f2f:[ 2f2f1b " 784 const std::string expected_string("2f:[ 2f1b 1b 2f2f:[ 2f2f1b "
785 "2f2f2b 2f2f3b ] 2f3b ] 3b 4f:[ 4f1f:[ 4f1f1b 4f1f2b 4f1f3b ] 4f2f:[ " 785 "2f2f2b 2f2f3b ] 2f3b ] 3b 4f:[ 4f1f:[ 4f1f1b 4f1f2b 4f1f3b ] 4f2f:[ "
786 "4f2f1b 4f2f2b 4f2f3b ] 4f3f:[ 4f3f1b 4f3f2b 4f3f3b ] ] 5b "); 786 "4f2f1b 4f2f2b 4f2f3b ] 4f3f:[ 4f3f1b 4f3f2b 4f3f3b ] ] 5b ");
(...skipping 491 matching lines...) Expand 10 before | Expand all | Expand 10 after
1278 1278
1279 // Pop open the new folder window and verify it has one (empty) item. 1279 // Pop open the new folder window and verify it has one (empty) item.
1280 BookmarkButton* button = [bar_ buttonWithTitleEqualTo:@"BIG"]; 1280 BookmarkButton* button = [bar_ buttonWithTitleEqualTo:@"BIG"];
1281 [[button target] performSelector:@selector(openBookmarkFolderFromButton:) 1281 [[button target] performSelector:@selector(openBookmarkFolderFromButton:)
1282 withObject:button]; 1282 withObject:button];
1283 BookmarkBarFolderController* folderController = [bar_ folderController]; 1283 BookmarkBarFolderController* folderController = [bar_ folderController];
1284 EXPECT_TRUE(folderController); 1284 EXPECT_TRUE(folderController);
1285 NSWindow* folderWindow = [folderController window]; 1285 NSWindow* folderWindow = [folderController window];
1286 EXPECT_TRUE(folderWindow); 1286 EXPECT_TRUE(folderWindow);
1287 CGFloat expectedHeight = (CGFloat)bookmarks::kBookmarkFolderButtonHeight + 1287 CGFloat expectedHeight = (CGFloat)bookmarks::kBookmarkFolderButtonHeight +
1288 (2*bookmarks::BookmarkVerticalPadding()); 1288 (2*bookmarks::kBookmarkVerticalPadding);
1289 NSRect windowFrame = [folderWindow frame]; 1289 NSRect windowFrame = [folderWindow frame];
1290 CGFloat windowHeight = NSHeight(windowFrame); 1290 CGFloat windowHeight = NSHeight(windowFrame);
1291 EXPECT_CGFLOAT_EQ(expectedHeight, windowHeight); 1291 EXPECT_CGFLOAT_EQ(expectedHeight, windowHeight);
1292 EXPECT_FALSE([folderController canScrollUp]); 1292 EXPECT_FALSE([folderController canScrollUp]);
1293 EXPECT_FALSE([folderController canScrollDown]); 1293 EXPECT_FALSE([folderController canScrollDown]);
1294 1294
1295 // Now add a real bookmark and reopen. 1295 // Now add a real bookmark and reopen.
1296 model->AddURL(folder, folder->child_count(), ASCIIToUTF16("a"), 1296 model->AddURL(folder, folder->child_count(), ASCIIToUTF16("a"),
1297 GURL("http://a.com/")); 1297 GURL("http://a.com/"));
1298 folderController = [bar_ folderController]; 1298 folderController = [bar_ folderController];
(...skipping 287 matching lines...) Expand 10 before | Expand all | Expand 10 after
1586 EXPECT_EQ(model_string, actual); 1586 EXPECT_EQ(model_string, actual);
1587 1587
1588 // Pop open the folder. 1588 // Pop open the folder.
1589 BookmarkButton* button = [bar_ buttonWithTitleEqualTo:@"2f"]; 1589 BookmarkButton* button = [bar_ buttonWithTitleEqualTo:@"2f"];
1590 [[button target] performSelector:@selector(openBookmarkFolderFromButton:) 1590 [[button target] performSelector:@selector(openBookmarkFolderFromButton:)
1591 withObject:button]; 1591 withObject:button];
1592 BookmarkBarFolderController* folder = [bar_ folderController]; 1592 BookmarkBarFolderController* folder = [bar_ folderController];
1593 EXPECT_TRUE(folder); 1593 EXPECT_TRUE(folder);
1594 1594
1595 // Test a series of points starting at the top of the folder. 1595 // Test a series of points starting at the top of the folder.
1596 const CGFloat yOffset = 0.5 * bookmarks::BookmarkVerticalPadding(); 1596 const CGFloat yOffset = 0.5 * bookmarks::kBookmarkVerticalPadding;
1597 BookmarkButton* targetButton = [folder buttonWithTitleEqualTo:@"2f1b"]; 1597 BookmarkButton* targetButton = [folder buttonWithTitleEqualTo:@"2f1b"];
1598 ASSERT_TRUE(targetButton); 1598 ASSERT_TRUE(targetButton);
1599 NSPoint targetPoint = [targetButton top]; 1599 NSPoint targetPoint = [targetButton top];
1600 CGFloat pos = [folder indicatorPosForDragToPoint:targetPoint]; 1600 CGFloat pos = [folder indicatorPosForDragToPoint:targetPoint];
1601 EXPECT_CGFLOAT_EQ(targetPoint.y + yOffset, pos); 1601 EXPECT_CGFLOAT_EQ(targetPoint.y + yOffset, pos);
1602 pos = [folder indicatorPosForDragToPoint:[targetButton bottom]]; 1602 pos = [folder indicatorPosForDragToPoint:[targetButton bottom]];
1603 targetButton = [folder buttonWithTitleEqualTo:@"2f2f"]; 1603 targetButton = [folder buttonWithTitleEqualTo:@"2f2f"];
1604 EXPECT_CGFLOAT_EQ([targetButton top].y + yOffset, pos); 1604 EXPECT_CGFLOAT_EQ([targetButton top].y + yOffset, pos);
1605 pos = [folder indicatorPosForDragToPoint:NSMakePoint(10,0)]; 1605 pos = [folder indicatorPosForDragToPoint:NSMakePoint(10,0)];
1606 targetButton = [folder buttonWithTitleEqualTo:@"2f3b"]; 1606 targetButton = [folder buttonWithTitleEqualTo:@"2f3b"];
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
1662 DeleteBookmark([folder parentButton], profile()); 1662 DeleteBookmark([folder parentButton], profile());
1663 EXPECT_FALSE([folder folderController]); 1663 EXPECT_FALSE([folder folderController]);
1664 } 1664 }
1665 1665
1666 // TODO(jrg): draggingEntered: and draggingExited: trigger timers so 1666 // TODO(jrg): draggingEntered: and draggingExited: trigger timers so
1667 // they are hard to test. Factor out "fire timers" into routines 1667 // they are hard to test. Factor out "fire timers" into routines
1668 // which can be overridden to fire immediately to make behavior 1668 // which can be overridden to fire immediately to make behavior
1669 // confirmable. 1669 // confirmable.
1670 // There is a similar problem with mouseEnteredButton: and 1670 // There is a similar problem with mouseEnteredButton: and
1671 // mouseExitedButton:. 1671 // mouseExitedButton:.
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698