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

Side by Side Diff: chrome/browser/cocoa/bookmark_bar_controller_unittest.mm

Issue 2799015: When deleting bookmark buttons, make sure all delayed messages... (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' Created 10 years, 6 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 | Annotate | Revision Log
« no previous file with comments | « no previous file | chrome/browser/cocoa/bookmark_bar_folder_controller.mm » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2009 The Chromium Authors. All rights reserved.
Bons 2010/06/18 01:32:55 2010
John Grabowski 2010/06/18 01:54:46 Not sure what our convention is, but I generally i
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 "app/theme_provider.h" 7 #include "app/theme_provider.h"
8 #include "base/basictypes.h" 8 #include "base/basictypes.h"
9 #include "base/scoped_nsobject.h" 9 #include "base/scoped_nsobject.h"
10 #include "base/string_util.h"
10 #include "base/sys_string_conversions.h" 11 #include "base/sys_string_conversions.h"
11 #import "chrome/browser/cocoa/bookmark_bar_constants.h" 12 #import "chrome/browser/cocoa/bookmark_bar_constants.h"
12 #import "chrome/browser/cocoa/bookmark_bar_controller.h" 13 #import "chrome/browser/cocoa/bookmark_bar_controller.h"
13 #import "chrome/browser/cocoa/bookmark_bar_folder_window.h" 14 #import "chrome/browser/cocoa/bookmark_bar_folder_window.h"
14 #import "chrome/browser/cocoa/bookmark_bar_unittest_helper.h" 15 #import "chrome/browser/cocoa/bookmark_bar_unittest_helper.h"
15 #import "chrome/browser/cocoa/bookmark_bar_view.h" 16 #import "chrome/browser/cocoa/bookmark_bar_view.h"
16 #import "chrome/browser/cocoa/bookmark_button.h" 17 #import "chrome/browser/cocoa/bookmark_button.h"
17 #import "chrome/browser/cocoa/bookmark_button_cell.h" 18 #import "chrome/browser/cocoa/bookmark_button_cell.h"
18 #import "chrome/browser/cocoa/bookmark_menu.h" 19 #import "chrome/browser/cocoa/bookmark_menu.h"
19 #include "chrome/browser/cocoa/browser_test_helper.h" 20 #include "chrome/browser/cocoa/browser_test_helper.h"
(...skipping 557 matching lines...) Expand 10 before | Expand all | Expand 10 after
577 // If last one make sure the menu is closed and the button is hidden. 578 // If last one make sure the menu is closed and the button is hidden.
578 // Else make sure menu stays open. 579 // Else make sure menu stays open.
579 if ([bar_ offTheSideButtonIsHidden]) { 580 if ([bar_ offTheSideButtonIsHidden]) {
580 EXPECT_FALSE([bar_ folderController]); 581 EXPECT_FALSE([bar_ folderController]);
581 } else { 582 } else {
582 EXPECT_TRUE([bar_ folderController]); 583 EXPECT_TRUE([bar_ folderController]);
583 } 584 }
584 } 585 }
585 } 586 }
586 587
588 // http://crbug.com/46175 is a crash when deleting bookmarks from the
589 // off-the-side menu while it is open. This test tries to bang hard
590 // in this area to reproduce the crash.
591 TEST_F(BookmarkBarControllerTest, DeleteFromOffTheSideWhileItIsOpen) {
592 BookmarkModel* model = helper_.profile()->GetBookmarkModel();
593 [bar_ setIgnoreAnimations:YES];
594 [bar_ loaded:model];
595
596 // Add a lot of bookmarks (per the bug).
597 const BookmarkNode* parent = model->GetBookmarkBarNode();
598 for (int i = 0; i < 100; i++) {
Bons 2010/06/18 01:32:55 ++i (C++ style guide nagging in my BRAIN)
John Grabowski 2010/06/18 01:54:46 From the style guide, "For simple scalar (non-obje
599 std::ostringstream title;
600 title << "super duper wide title " << i;
601 model->AddURL(parent, parent->GetChildCount(),
602 ASCIIToWide(title.str().c_str()),
603 GURL("http://superfriends.hall-of-justice.edu"));
Bons 2010/06/18 01:32:55 nice.
604 }
605 EXPECT_FALSE([bar_ offTheSideButtonIsHidden]);
606
607 // Open "off the side" menu.
608 NSButton* offTheSideButton = [bar_ offTheSideButton];
609 [bar_ openBookmarkFolderFromButton:offTheSideButton];
610 BookmarkBarFolderController* bbfc = [bar_ folderController];
611 EXPECT_TRUE(bbfc);
612 [bbfc setIgnoreAnimations:YES];
613
614 // Start deleting items; try and delete randomish ones in case it
615 // makes a difference.
616 int indices[] = { 2, 4, 5, 1, 7, 9, 2, 0, 10, 9 };
617 while (parent->GetChildCount()) {
618 for (unsigned int i = 0; i < arraysize(indices); i++) {
619 if (indices[i] < parent->GetChildCount()) {
620 // First we mouse-enter the button to make things harder.
621 NSArray* buttons = [bbfc buttons];
622 for (BookmarkButton* button in buttons) {
623 if ([button bookmarkNode] == parent->GetChild(indices[i])) {
624 [bbfc mouseEnteredButton:button event:nil];
625 break;
626 }
627 }
628 // Then we remove the node. This triggers the button to get
629 // deleted.
630 model->Remove(parent, indices[i]);
631 // Force visual update which is otherwise delayed.
632 [[bbfc window] displayIfNeeded];
633 }
634 }
635 }
636 }
637
587 // Test whether |-dragShouldLockBarVisibility| returns NO iff the bar is 638 // Test whether |-dragShouldLockBarVisibility| returns NO iff the bar is
588 // detached. 639 // detached.
589 TEST_F(BookmarkBarControllerTest, TestDragShouldLockBarVisibility) { 640 TEST_F(BookmarkBarControllerTest, TestDragShouldLockBarVisibility) {
590 [bar_ updateAndShowNormalBar:NO 641 [bar_ updateAndShowNormalBar:NO
591 showDetachedBar:NO 642 showDetachedBar:NO
592 withAnimation:NO]; 643 withAnimation:NO];
593 EXPECT_TRUE([bar_ dragShouldLockBarVisibility]); 644 EXPECT_TRUE([bar_ dragShouldLockBarVisibility]);
594 645
595 [bar_ updateAndShowNormalBar:YES 646 [bar_ updateAndShowNormalBar:YES
596 showDetachedBar:NO 647 showDetachedBar:NO
(...skipping 1378 matching lines...) Expand 10 before | Expand all | Expand 10 after
1975 EXPECT_CGFLOAT_EQ(expected, actual); 2026 EXPECT_CGFLOAT_EQ(expected, actual);
1976 targetButton = [bar_ buttonWithTitleEqualTo:@"4b"]; 2027 targetButton = [bar_ buttonWithTitleEqualTo:@"4b"];
1977 targetPoint = [targetButton right]; 2028 targetPoint = [targetButton right];
1978 targetPoint.x += 100; // Somewhere off to the right. 2029 targetPoint.x += 100; // Somewhere off to the right.
1979 expected = NSMaxX([targetButton frame]) + xDelta; 2030 expected = NSMaxX([targetButton frame]) + xDelta;
1980 actual = [bar_ indicatorPosForDragToPoint:targetPoint]; 2031 actual = [bar_ indicatorPosForDragToPoint:targetPoint];
1981 EXPECT_CGFLOAT_EQ(expected, actual); 2032 EXPECT_CGFLOAT_EQ(expected, actual);
1982 } 2033 }
1983 2034
1984 } // namespace 2035 } // namespace
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/cocoa/bookmark_bar_folder_controller.mm » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698