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

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

Issue 7048009: [Mac] Fix "No drag (+) cursor displayed when dragging link over BMB" (Closed) Base URL: http://src.chromium.org/svn/trunk/src/
Patch Set: '' Created 9 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 | Annotate | Revision Log
« no previous file with comments | « chrome/browser/ui/cocoa/bookmarks/bookmark_bar_view.mm ('k') | no next file » | 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) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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 "base/memory/scoped_nsobject.h" 5 #include "base/memory/scoped_nsobject.h"
6 #import "chrome/browser/ui/cocoa/bookmarks/bookmark_bar_controller.h" 6 #import "chrome/browser/ui/cocoa/bookmarks/bookmark_bar_controller.h"
7 #import "chrome/browser/ui/cocoa/bookmarks/bookmark_bar_view.h" 7 #import "chrome/browser/ui/cocoa/bookmarks/bookmark_bar_view.h"
8 #import "chrome/browser/ui/cocoa/bookmarks/bookmark_button.h" 8 #import "chrome/browser/ui/cocoa/bookmarks/bookmark_button.h"
9 #import "chrome/browser/ui/cocoa/bookmarks/bookmark_folder_target.h" 9 #import "chrome/browser/ui/cocoa/bookmarks/bookmark_folder_target.h"
10 #import "chrome/browser/ui/cocoa/cocoa_test_helper.h" 10 #import "chrome/browser/ui/cocoa/cocoa_test_helper.h"
11 #import "chrome/browser/ui/cocoa/url_drop_target.h" 11 #import "chrome/browser/ui/cocoa/url_drop_target.h"
12 #include "testing/gtest/include/gtest/gtest.h" 12 #include "testing/gtest/include/gtest/gtest.h"
13 #include "testing/platform_test.h" 13 #include "testing/platform_test.h"
14 #import "third_party/mozilla/NSPasteboard+Utils.h" 14 #import "third_party/mozilla/NSPasteboard+Utils.h"
15 15
16 namespace { 16 namespace {
17 const CGFloat kFakeIndicatorPos = 7.0; 17 const CGFloat kFakeIndicatorPos = 7.0;
18 }; 18 };
19 19
20 // Fake DraggingInfo, fake BookmarkBarController, fake NSPasteboard... 20 // Fake DraggingInfo, fake BookmarkBarController, fake NSPasteboard...
21 @interface FakeBookmarkDraggingInfo : NSObject { 21 @interface FakeBookmarkDraggingInfo : NSObject {
22 @public 22 @public
23 BOOL dragButtonToPong_; 23 BOOL dragButtonToPong_;
24 BOOL dragURLsPong_; 24 BOOL dragURLsPong_;
25 BOOL dragBookmarkDataPong_; 25 BOOL dragBookmarkDataPong_;
26 BOOL dropIndicatorShown_; 26 BOOL dropIndicatorShown_;
27 BOOL draggingEnteredCalled_; 27 BOOL draggingEnteredCalled_;
28 // Only mock one type of drag data at a time. 28 // Only mock one type of drag data at a time.
29 NSString* dragDataType_; 29 NSString* dragDataType_;
30 id draggingSource_;
30 } 31 }
31 @property (nonatomic) BOOL dropIndicatorShown; 32 @property (nonatomic) BOOL dropIndicatorShown;
32 @property (nonatomic) BOOL draggingEnteredCalled; 33 @property (nonatomic) BOOL draggingEnteredCalled;
33 @property (nonatomic, copy) NSString* dragDataType; 34 @property (nonatomic, copy) NSString* dragDataType;
34 @end 35 @end
35 36
36 @implementation FakeBookmarkDraggingInfo 37 @implementation FakeBookmarkDraggingInfo
37 38
38 @synthesize dropIndicatorShown = dropIndicatorShown_; 39 @synthesize dropIndicatorShown = dropIndicatorShown_;
39 @synthesize draggingEnteredCalled = draggingEnteredCalled_; 40 @synthesize draggingEnteredCalled = draggingEnteredCalled_;
(...skipping 12 matching lines...) Expand all
52 } 53 }
53 54
54 - (void)reset { 55 - (void)reset {
55 [dragDataType_ release]; 56 [dragDataType_ release];
56 dragDataType_ = nil; 57 dragDataType_ = nil;
57 dragButtonToPong_ = NO; 58 dragButtonToPong_ = NO;
58 dragURLsPong_ = NO; 59 dragURLsPong_ = NO;
59 dragBookmarkDataPong_ = NO; 60 dragBookmarkDataPong_ = NO;
60 dropIndicatorShown_ = YES; 61 dropIndicatorShown_ = YES;
61 draggingEnteredCalled_ = NO; 62 draggingEnteredCalled_ = NO;
63 draggingSource_ = self;
64 }
65
66 - (void)setDraggingSource:(id)draggingSource {
67 draggingSource_ = draggingSource;
62 } 68 }
63 69
64 // NSDragInfo mocking functions. 70 // NSDragInfo mocking functions.
65 71
66 - (id)draggingPasteboard { 72 - (id)draggingPasteboard {
67 return self; 73 return self;
68 } 74 }
69 75
70 // So we can look local. 76 // So we can look local.
71 - (id)draggingSource { 77 - (id)draggingSource {
72 return self; 78 return draggingSource_;
73 } 79 }
74 80
75 - (NSDragOperation)draggingSourceOperationMask { 81 - (NSDragOperation)draggingSourceOperationMask {
76 return NSDragOperationCopy | NSDragOperationMove; 82 return NSDragOperationCopy | NSDragOperationMove;
77 } 83 }
78 84
79 - (NSPoint)draggingLocation { 85 - (NSPoint)draggingLocation {
80 return NSMakePoint(10, 10); 86 return NSMakePoint(10, 10);
81 } 87 }
82 88
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after
175 TEST_F(BookmarkBarViewTest, CanDragWindow) { 181 TEST_F(BookmarkBarViewTest, CanDragWindow) {
176 EXPECT_FALSE([view_ mouseDownCanMoveWindow]); 182 EXPECT_FALSE([view_ mouseDownCanMoveWindow]);
177 } 183 }
178 184
179 TEST_F(BookmarkBarViewTest, BookmarkButtonDragAndDrop) { 185 TEST_F(BookmarkBarViewTest, BookmarkButtonDragAndDrop) {
180 scoped_nsobject<FakeBookmarkDraggingInfo> 186 scoped_nsobject<FakeBookmarkDraggingInfo>
181 info([[FakeBookmarkDraggingInfo alloc] init]); 187 info([[FakeBookmarkDraggingInfo alloc] init]);
182 [view_ setController:info.get()]; 188 [view_ setController:info.get()];
183 [info reset]; 189 [info reset];
184 190
191 scoped_nsobject<BookmarkButton> dragged_button([[BookmarkButton alloc] init]);
192 [info setDraggingSource:dragged_button.get()];
185 [info setDragDataType:kBookmarkButtonDragType]; 193 [info setDragDataType:kBookmarkButtonDragType];
186 EXPECT_EQ([view_ draggingEntered:(id)info.get()], NSDragOperationMove); 194 EXPECT_EQ([view_ draggingEntered:(id)info.get()], NSDragOperationMove);
187 EXPECT_TRUE([view_ performDragOperation:(id)info.get()]); 195 EXPECT_TRUE([view_ performDragOperation:(id)info.get()]);
188 EXPECT_TRUE([info dragButtonToPong]); 196 EXPECT_TRUE([info dragButtonToPong]);
189 EXPECT_FALSE([info dragURLsPong]); 197 EXPECT_FALSE([info dragURLsPong]);
190 EXPECT_TRUE([info dragBookmarkDataPong]); 198 EXPECT_TRUE([info dragBookmarkDataPong]);
191 } 199 }
192 200
193 TEST_F(BookmarkBarViewTest, URLDragAndDrop) { 201 TEST_F(BookmarkBarViewTest, URLDragAndDrop) {
194 scoped_nsobject<FakeBookmarkDraggingInfo> 202 scoped_nsobject<FakeBookmarkDraggingInfo>
195 info([[FakeBookmarkDraggingInfo alloc] init]); 203 info([[FakeBookmarkDraggingInfo alloc] init]);
196 [view_ setController:info.get()]; 204 [view_ setController:info.get()];
197 [info reset]; 205 [info reset];
198 206
199 NSArray* dragTypes = [URLDropTargetHandler handledDragTypes]; 207 NSArray* dragTypes = [URLDropTargetHandler handledDragTypes];
200 for (NSString* type in dragTypes) { 208 for (NSString* type in dragTypes) {
201 [info setDragDataType:type]; 209 [info setDragDataType:type];
202 EXPECT_EQ([view_ draggingEntered:(id)info.get()], NSDragOperationMove); 210 EXPECT_EQ([view_ draggingEntered:(id)info.get()], NSDragOperationCopy);
203 EXPECT_TRUE([view_ performDragOperation:(id)info.get()]); 211 EXPECT_TRUE([view_ performDragOperation:(id)info.get()]);
204 EXPECT_FALSE([info dragButtonToPong]); 212 EXPECT_FALSE([info dragButtonToPong]);
205 EXPECT_TRUE([info dragURLsPong]); 213 EXPECT_TRUE([info dragURLsPong]);
206 EXPECT_TRUE([info dragBookmarkDataPong]); 214 EXPECT_TRUE([info dragBookmarkDataPong]);
207 [info reset]; 215 [info reset];
208 } 216 }
209 } 217 }
210 218
211 TEST_F(BookmarkBarViewTest, BookmarkButtonDropIndicator) { 219 TEST_F(BookmarkBarViewTest, BookmarkButtonDropIndicator) {
212 scoped_nsobject<FakeBookmarkDraggingInfo> 220 scoped_nsobject<FakeBookmarkDraggingInfo>
213 info([[FakeBookmarkDraggingInfo alloc] init]); 221 info([[FakeBookmarkDraggingInfo alloc] init]);
214 [view_ setController:info.get()]; 222 [view_ setController:info.get()];
223 [info reset];
215 224
216 [info reset]; 225 scoped_nsobject<BookmarkButton> dragged_button([[BookmarkButton alloc] init]);
226 [info setDraggingSource:dragged_button.get()];
217 [info setDragDataType:kBookmarkButtonDragType]; 227 [info setDragDataType:kBookmarkButtonDragType];
218 EXPECT_FALSE([info draggingEnteredCalled]); 228 EXPECT_FALSE([info draggingEnteredCalled]);
219 EXPECT_EQ([view_ draggingEntered:(id)info.get()], NSDragOperationMove); 229 EXPECT_EQ([view_ draggingEntered:(id)info.get()], NSDragOperationMove);
220 EXPECT_TRUE([info draggingEnteredCalled]); // Ensure controller pinged. 230 EXPECT_TRUE([info draggingEnteredCalled]); // Ensure controller pinged.
221 EXPECT_TRUE([view_ dropIndicatorShown]); 231 EXPECT_TRUE([view_ dropIndicatorShown]);
222 EXPECT_EQ([view_ dropIndicatorPosition], kFakeIndicatorPos); 232 EXPECT_EQ([view_ dropIndicatorPosition], kFakeIndicatorPos);
223 233
224 [info setDropIndicatorShown:NO]; 234 [info setDropIndicatorShown:NO];
225 EXPECT_EQ([view_ draggingEntered:(id)info.get()], NSDragOperationMove); 235 EXPECT_EQ([view_ draggingEntered:(id)info.get()], NSDragOperationMove);
226 EXPECT_FALSE([view_ dropIndicatorShown]); 236 EXPECT_FALSE([view_ dropIndicatorShown]);
227 } 237 }
228 238
229 } // namespace 239 } // namespace
OLDNEW
« no previous file with comments | « chrome/browser/ui/cocoa/bookmarks/bookmark_bar_view.mm ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698