[Mac] Fix "No drag (+) cursor displayed when dragging link over BMB"

Return NSDragOperationCopy for BookmarBarButton drags and NSDragOperationMove
for other drag types. Updated unit tests to set a BookmarkBarButton as the
mock |draggingSource| for bookmark bar dragging tests and made the tests
check for the expected drag operation type.

BUG=83228
TEST=Drag a link from a page and hover over the BMB. Cursor should be a (+).
Drag a bookmark button. Cursor shouldn't be a (+).

Review URL: http://codereview.chromium.org/7048009

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@86696 0039d316-1c4b-4281-b951-d872f2087c98
parent f2616568
......@@ -155,7 +155,8 @@
}
[controller_ draggingEntered:info]; // allow hover-open to work.
return [info draggingSource] ? NSDragOperationMove : NSDragOperationCopy;
return [[info draggingSource] isKindOfClass: [BookmarkButton class]] ?
NSDragOperationMove : NSDragOperationCopy;
}
return NSDragOperationNone;
}
......
......@@ -27,6 +27,7 @@ namespace {
BOOL draggingEnteredCalled_;
// Only mock one type of drag data at a time.
NSString* dragDataType_;
id draggingSource_;
}
@property (nonatomic) BOOL dropIndicatorShown;
@property (nonatomic) BOOL draggingEnteredCalled;
......@@ -59,6 +60,11 @@ namespace {
dragBookmarkDataPong_ = NO;
dropIndicatorShown_ = YES;
draggingEnteredCalled_ = NO;
draggingSource_ = self;
}
- (void)setDraggingSource:(id)draggingSource {
draggingSource_ = draggingSource;
}
// NSDragInfo mocking functions.
......@@ -69,7 +75,7 @@ namespace {
// So we can look local.
- (id)draggingSource {
return self;
return draggingSource_;
}
- (NSDragOperation)draggingSourceOperationMask {
......@@ -182,6 +188,8 @@ TEST_F(BookmarkBarViewTest, BookmarkButtonDragAndDrop) {
[view_ setController:info.get()];
[info reset];
scoped_nsobject<BookmarkButton> dragged_button([[BookmarkButton alloc] init]);
[info setDraggingSource:dragged_button.get()];
[info setDragDataType:kBookmarkButtonDragType];
EXPECT_EQ([view_ draggingEntered:(id)info.get()], NSDragOperationMove);
EXPECT_TRUE([view_ performDragOperation:(id)info.get()]);
......@@ -199,7 +207,7 @@ TEST_F(BookmarkBarViewTest, URLDragAndDrop) {
NSArray* dragTypes = [URLDropTargetHandler handledDragTypes];
for (NSString* type in dragTypes) {
[info setDragDataType:type];
EXPECT_EQ([view_ draggingEntered:(id)info.get()], NSDragOperationMove);
EXPECT_EQ([view_ draggingEntered:(id)info.get()], NSDragOperationCopy);
EXPECT_TRUE([view_ performDragOperation:(id)info.get()]);
EXPECT_FALSE([info dragButtonToPong]);
EXPECT_TRUE([info dragURLsPong]);
......@@ -212,8 +220,10 @@ TEST_F(BookmarkBarViewTest, BookmarkButtonDropIndicator) {
scoped_nsobject<FakeBookmarkDraggingInfo>
info([[FakeBookmarkDraggingInfo alloc] init]);
[view_ setController:info.get()];
[info reset];
scoped_nsobject<BookmarkButton> dragged_button([[BookmarkButton alloc] init]);
[info setDraggingSource:dragged_button.get()];
[info setDragDataType:kBookmarkButtonDragType];
EXPECT_FALSE([info draggingEnteredCalled]);
EXPECT_EQ([view_ draggingEntered:(id)info.get()], NSDragOperationMove);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment