| 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 1375 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1386 [bbfc mouseEnteredButton:button event:nil]; | 1386 [bbfc mouseEnteredButton:button event:nil]; |
| 1387 buttonThatMouseIsIn = [bbfc buttonThatMouseIsIn]; | 1387 buttonThatMouseIsIn = [bbfc buttonThatMouseIsIn]; |
| 1388 EXPECT_EQ(button, buttonThatMouseIsIn); | 1388 EXPECT_EQ(button, buttonThatMouseIsIn); |
| 1389 | 1389 |
| 1390 // Delete the bookmark and verify that it is now not known. | 1390 // Delete the bookmark and verify that it is now not known. |
| 1391 model->Remove(folder->GetChild(3)); | 1391 model->Remove(folder->GetChild(3)); |
| 1392 buttonThatMouseIsIn = [bbfc buttonThatMouseIsIn]; | 1392 buttonThatMouseIsIn = [bbfc buttonThatMouseIsIn]; |
| 1393 EXPECT_FALSE(buttonThatMouseIsIn); | 1393 EXPECT_FALSE(buttonThatMouseIsIn); |
| 1394 } | 1394 } |
| 1395 | 1395 |
| 1396 // Tests that sending keyboard events to the (empty) button in an empty |
| 1397 // folder menu does not crash. https://crbug.com/690424 |
| 1398 TEST_F(BookmarkBarFolderControllerMenuTest, ActOnEmptyMenu) { |
| 1399 BookmarkModel* model = BookmarkModelFactory::GetForBrowserContext(profile()); |
| 1400 const BookmarkNode* root = model->bookmark_bar_node(); |
| 1401 const BookmarkNode* folder = |
| 1402 model->AddFolder(root, root->child_count(), ASCIIToUTF16("empty")); |
| 1403 ASSERT_TRUE(folder); |
| 1404 |
| 1405 BookmarkButton* button = [bar_ buttonWithTitleEqualTo:@"empty"]; |
| 1406 [[button target] performSelector:@selector(openBookmarkFolderFromButton:) |
| 1407 withObject:button]; |
| 1408 |
| 1409 BookmarkBarFolderController* bbfc = [bar_ folderController]; |
| 1410 NSArray* buttons = [bbfc buttons]; |
| 1411 ASSERT_EQ(1u, [buttons count]); |
| 1412 |
| 1413 button = [buttons objectAtIndex:0]; |
| 1414 EXPECT_TRUE([button isEmpty]); |
| 1415 |
| 1416 [bbfc mouseEnteredButton:button event:nil]; |
| 1417 |
| 1418 EXPECT_TRUE([bbfc handleInputText:@" "]); |
| 1419 } |
| 1420 |
| 1396 // Just like a BookmarkBarFolderController but intercedes when providing | 1421 // Just like a BookmarkBarFolderController but intercedes when providing |
| 1397 // pasteboard drag data. | 1422 // pasteboard drag data. |
| 1398 @interface BookmarkBarFolderControllerDragData : BookmarkBarFolderController { | 1423 @interface BookmarkBarFolderControllerDragData : BookmarkBarFolderController { |
| 1399 const BookmarkNode* dragDataNode_; // Weak | 1424 const BookmarkNode* dragDataNode_; // Weak |
| 1400 } | 1425 } |
| 1401 - (void)setDragDataNode:(const BookmarkNode*)node; | 1426 - (void)setDragDataNode:(const BookmarkNode*)node; |
| 1402 @end | 1427 @end |
| 1403 | 1428 |
| 1404 @implementation BookmarkBarFolderControllerDragData | 1429 @implementation BookmarkBarFolderControllerDragData |
| 1405 | 1430 |
| (...skipping 293 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1699 DeleteBookmark([folder parentButton], profile()); | 1724 DeleteBookmark([folder parentButton], profile()); |
| 1700 EXPECT_FALSE([folder folderController]); | 1725 EXPECT_FALSE([folder folderController]); |
| 1701 } | 1726 } |
| 1702 | 1727 |
| 1703 // TODO(jrg): draggingEntered: and draggingExited: trigger timers so | 1728 // TODO(jrg): draggingEntered: and draggingExited: trigger timers so |
| 1704 // they are hard to test. Factor out "fire timers" into routines | 1729 // they are hard to test. Factor out "fire timers" into routines |
| 1705 // which can be overridden to fire immediately to make behavior | 1730 // which can be overridden to fire immediately to make behavior |
| 1706 // confirmable. | 1731 // confirmable. |
| 1707 // There is a similar problem with mouseEnteredButton: and | 1732 // There is a similar problem with mouseEnteredButton: and |
| 1708 // mouseExitedButton:. | 1733 // mouseExitedButton:. |
| OLD | NEW |