| 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 "base/mac/scoped_nsobject.h" | 5 #include "base/mac/scoped_nsobject.h" |
| 6 #include "base/strings/string16.h" | 6 #include "base/strings/string16.h" |
| 7 #include "base/strings/utf_string_conversions.h" | 7 #include "base/strings/utf_string_conversions.h" |
| 8 #include "chrome/browser/bookmarks/bookmark_model_factory.h" | 8 #include "chrome/browser/bookmarks/bookmark_model_factory.h" |
| 9 #include "chrome/browser/profiles/profile.h" | 9 #include "chrome/browser/profiles/profile.h" |
| 10 #import "chrome/browser/ui/cocoa/bookmarks/bookmark_bar_controller.h" | 10 #import "chrome/browser/ui/cocoa/bookmarks/bookmark_bar_controller.h" |
| (...skipping 17 matching lines...) Expand all Loading... |
| 28 | 28 |
| 29 namespace { | 29 namespace { |
| 30 | 30 |
| 31 // Some values used for mocks and fakes. | 31 // Some values used for mocks and fakes. |
| 32 const CGFloat kFakeIndicatorPos = 7.0; | 32 const CGFloat kFakeIndicatorPos = 7.0; |
| 33 const NSPoint kPoint = {10, 10}; | 33 const NSPoint kPoint = {10, 10}; |
| 34 | 34 |
| 35 } // namespace | 35 } // namespace |
| 36 | 36 |
| 37 // Fake DraggingInfo, fake BookmarkBarController, fake NSPasteboard... | 37 // Fake DraggingInfo, fake BookmarkBarController, fake NSPasteboard... |
| 38 @interface FakeBookmarkDraggingInfo : NSObject { | 38 @interface FakeBookmarkDraggingInfo : BookmarkBarController { |
| 39 @public | 39 @public |
| 40 BOOL dragButtonToPong_; | 40 BOOL dragButtonToPong_; |
| 41 BOOL dragButtonToShouldCopy_; | 41 BOOL dragButtonToShouldCopy_; |
| 42 BOOL dragURLsPong_; | 42 BOOL dragURLsPong_; |
| 43 BOOL dragBookmarkDataPong_; | 43 BOOL dragBookmarkDataPong_; |
| 44 BOOL dropIndicatorShown_; | 44 BOOL dropIndicatorShown_; |
| 45 BOOL draggingEnteredCalled_; | 45 BOOL draggingEnteredCalled_; |
| 46 // Only mock one type of drag data at a time. | 46 // Only mock one type of drag data at a time. |
| 47 NSString* dragDataType_; | 47 NSString* dragDataType_; |
| 48 BookmarkButton* button_; // weak | 48 BookmarkButton* button_; // weak |
| 49 BookmarkModel* bookmarkModel_; // weak | 49 BookmarkModel* stubbedBookmarkModel_; // weak |
| 50 id draggingSource_; | 50 id draggingSource_; |
| 51 } | 51 } |
| 52 @property (nonatomic) BOOL dropIndicatorShown; | 52 @property (nonatomic) BOOL dropIndicatorShown; |
| 53 @property (nonatomic) BOOL draggingEnteredCalled; | 53 @property (nonatomic) BOOL draggingEnteredCalled; |
| 54 @property (nonatomic, copy) NSString* dragDataType; | 54 @property (nonatomic, copy) NSString* dragDataType; |
| 55 @property (nonatomic, assign) BookmarkButton* button; | 55 @property (nonatomic, assign) BookmarkButton* button; |
| 56 @property (nonatomic, assign) BookmarkModel* bookmarkModel; | 56 |
| 57 @end | 57 @end |
| 58 | 58 |
| 59 @implementation FakeBookmarkDraggingInfo | 59 @implementation FakeBookmarkDraggingInfo |
| 60 | 60 |
| 61 @synthesize dropIndicatorShown = dropIndicatorShown_; | 61 @synthesize dropIndicatorShown = dropIndicatorShown_; |
| 62 @synthesize draggingEnteredCalled = draggingEnteredCalled_; | 62 @synthesize draggingEnteredCalled = draggingEnteredCalled_; |
| 63 @synthesize dragDataType = dragDataType_; | 63 @synthesize dragDataType = dragDataType_; |
| 64 @synthesize button = button_; | 64 @synthesize button = button_; |
| 65 @synthesize bookmarkModel = bookmarkModel_; | |
| 66 | 65 |
| 67 - (id)init { | 66 - (id)init { |
| 68 if ((self = [super init])) { | 67 if ((self = [super init])) { |
| 69 dropIndicatorShown_ = YES; | 68 dropIndicatorShown_ = YES; |
| 70 } | 69 } |
| 71 return self; | 70 return self; |
| 72 } | 71 } |
| 73 | 72 |
| 74 - (void)dealloc { | 73 - (void)dealloc { |
| 75 [dragDataType_ release]; | 74 [dragDataType_ release]; |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 124 if (button_) | 123 if (button_) |
| 125 return [NSData dataWithBytes:&button_ length:sizeof(button_)]; | 124 return [NSData dataWithBytes:&button_ length:sizeof(button_)]; |
| 126 else | 125 else |
| 127 return [NSData data]; // Return something, anything. | 126 return [NSData data]; // Return something, anything. |
| 128 } | 127 } |
| 129 return nil; | 128 return nil; |
| 130 } | 129 } |
| 131 | 130 |
| 132 // Fake a controller for callback ponging | 131 // Fake a controller for callback ponging |
| 133 | 132 |
| 133 - (void)viewDidLoad { |
| 134 // no-op |
| 135 } |
| 136 |
| 137 - (void)setBookmarkModel:(BookmarkModel*)model { |
| 138 stubbedBookmarkModel_ = model; |
| 139 } |
| 140 |
| 141 - (BookmarkModel*)bookmarkModel { |
| 142 return stubbedBookmarkModel_; |
| 143 } |
| 144 |
| 134 - (BOOL)dragButton:(BookmarkButton*)button to:(NSPoint)point copy:(BOOL)copy { | 145 - (BOOL)dragButton:(BookmarkButton*)button to:(NSPoint)point copy:(BOOL)copy { |
| 135 dragButtonToPong_ = YES; | 146 dragButtonToPong_ = YES; |
| 136 dragButtonToShouldCopy_ = copy; | 147 dragButtonToShouldCopy_ = copy; |
| 137 return YES; | 148 return YES; |
| 138 } | 149 } |
| 139 | 150 |
| 140 - (BOOL)addURLs:(NSArray*)urls withTitles:(NSArray*)titles at:(NSPoint)point { | 151 - (BOOL)addURLs:(NSArray*)urls withTitles:(NSArray*)titles at:(NSPoint)point { |
| 141 dragURLsPong_ = YES; | 152 dragURLsPong_ = YES; |
| 142 return YES; | 153 return YES; |
| 143 } | 154 } |
| (...skipping 185 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 329 EXPECT_TRUE([info draggingEnteredCalled]); // Ensure controller pinged. | 340 EXPECT_TRUE([info draggingEnteredCalled]); // Ensure controller pinged. |
| 330 EXPECT_TRUE([view_ dropIndicatorShown]); | 341 EXPECT_TRUE([view_ dropIndicatorShown]); |
| 331 EXPECT_EQ([view_ dropIndicatorPosition], kFakeIndicatorPos); | 342 EXPECT_EQ([view_ dropIndicatorPosition], kFakeIndicatorPos); |
| 332 | 343 |
| 333 [info setDropIndicatorShown:NO]; | 344 [info setDropIndicatorShown:NO]; |
| 334 EXPECT_EQ([view_ draggingEntered:(id)info.get()], NSDragOperationMove); | 345 EXPECT_EQ([view_ draggingEntered:(id)info.get()], NSDragOperationMove); |
| 335 EXPECT_FALSE([view_ dropIndicatorShown]); | 346 EXPECT_FALSE([view_ dropIndicatorShown]); |
| 336 } | 347 } |
| 337 | 348 |
| 338 } // namespace | 349 } // namespace |
| OLD | NEW |