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

Unified 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | chrome/browser/cocoa/bookmark_bar_folder_controller.mm » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/cocoa/bookmark_bar_controller_unittest.mm
===================================================================
--- chrome/browser/cocoa/bookmark_bar_controller_unittest.mm (revision 49835)
+++ chrome/browser/cocoa/bookmark_bar_controller_unittest.mm (working copy)
@@ -7,6 +7,7 @@
#include "app/theme_provider.h"
#include "base/basictypes.h"
#include "base/scoped_nsobject.h"
+#include "base/string_util.h"
#include "base/sys_string_conversions.h"
#import "chrome/browser/cocoa/bookmark_bar_constants.h"
#import "chrome/browser/cocoa/bookmark_bar_controller.h"
@@ -584,6 +585,56 @@
}
}
+// http://crbug.com/46175 is a crash when deleting bookmarks from the
+// off-the-side menu while it is open. This test tries to bang hard
+// in this area to reproduce the crash.
+TEST_F(BookmarkBarControllerTest, DeleteFromOffTheSideWhileItIsOpen) {
+ BookmarkModel* model = helper_.profile()->GetBookmarkModel();
+ [bar_ setIgnoreAnimations:YES];
+ [bar_ loaded:model];
+
+ // Add a lot of bookmarks (per the bug).
+ const BookmarkNode* parent = model->GetBookmarkBarNode();
+ 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
+ std::ostringstream title;
+ title << "super duper wide title " << i;
+ model->AddURL(parent, parent->GetChildCount(),
+ ASCIIToWide(title.str().c_str()),
+ GURL("http://superfriends.hall-of-justice.edu"));
Bons 2010/06/18 01:32:55 nice.
+ }
+ EXPECT_FALSE([bar_ offTheSideButtonIsHidden]);
+
+ // Open "off the side" menu.
+ NSButton* offTheSideButton = [bar_ offTheSideButton];
+ [bar_ openBookmarkFolderFromButton:offTheSideButton];
+ BookmarkBarFolderController* bbfc = [bar_ folderController];
+ EXPECT_TRUE(bbfc);
+ [bbfc setIgnoreAnimations:YES];
+
+ // Start deleting items; try and delete randomish ones in case it
+ // makes a difference.
+ int indices[] = { 2, 4, 5, 1, 7, 9, 2, 0, 10, 9 };
+ while (parent->GetChildCount()) {
+ for (unsigned int i = 0; i < arraysize(indices); i++) {
+ if (indices[i] < parent->GetChildCount()) {
+ // First we mouse-enter the button to make things harder.
+ NSArray* buttons = [bbfc buttons];
+ for (BookmarkButton* button in buttons) {
+ if ([button bookmarkNode] == parent->GetChild(indices[i])) {
+ [bbfc mouseEnteredButton:button event:nil];
+ break;
+ }
+ }
+ // Then we remove the node. This triggers the button to get
+ // deleted.
+ model->Remove(parent, indices[i]);
+ // Force visual update which is otherwise delayed.
+ [[bbfc window] displayIfNeeded];
+ }
+ }
+ }
+}
+
// Test whether |-dragShouldLockBarVisibility| returns NO iff the bar is
// detached.
TEST_F(BookmarkBarControllerTest, TestDragShouldLockBarVisibility) {
« 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