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 205 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
216 EXPECT_FALSE([view_ mouseDownCanMoveWindow]); | 216 EXPECT_FALSE([view_ mouseDownCanMoveWindow]); |
217 } | 217 } |
218 | 218 |
219 TEST_F(BookmarkBarViewTest, BookmarkButtonDragAndDrop) { | 219 TEST_F(BookmarkBarViewTest, BookmarkButtonDragAndDrop) { |
220 base::scoped_nsobject<FakeBookmarkDraggingInfo> info( | 220 base::scoped_nsobject<FakeBookmarkDraggingInfo> info( |
221 [[FakeBookmarkDraggingInfo alloc] init]); | 221 [[FakeBookmarkDraggingInfo alloc] init]); |
222 [view_ setController:info.get()]; | 222 [view_ setController:info.get()]; |
223 [info reset]; | 223 [info reset]; |
224 | 224 |
225 BookmarkModel* bookmark_model = | 225 BookmarkModel* bookmark_model = |
226 BookmarkModelFactory::GetForProfile(profile()); | 226 BookmarkModelFactory::GetForBrowserContext(profile()); |
227 const BookmarkNode* node = | 227 const BookmarkNode* node = |
228 bookmark_model->AddURL(bookmark_model->bookmark_bar_node(), | 228 bookmark_model->AddURL(bookmark_model->bookmark_bar_node(), |
229 0, | 229 0, |
230 base::ASCIIToUTF16("Test Bookmark"), | 230 base::ASCIIToUTF16("Test Bookmark"), |
231 GURL("http://www.exmaple.com")); | 231 GURL("http://www.exmaple.com")); |
232 | 232 |
233 base::scoped_nsobject<BookmarkButtonCell> button_cell( | 233 base::scoped_nsobject<BookmarkButtonCell> button_cell( |
234 [[BookmarkButtonCell buttonCellForNode:node | 234 [[BookmarkButtonCell buttonCellForNode:node |
235 text:nil | 235 text:nil |
236 image:nil | 236 image:nil |
(...skipping 20 matching lines...) Expand all Loading... |
257 [[FakeBookmarkDraggingInfo alloc] init]); | 257 [[FakeBookmarkDraggingInfo alloc] init]); |
258 [view_ setController:info.get()]; | 258 [view_ setController:info.get()]; |
259 [info reset]; | 259 [info reset]; |
260 | 260 |
261 // |other_profile| is owned by the |testing_profile_manager|. | 261 // |other_profile| is owned by the |testing_profile_manager|. |
262 TestingProfile* other_profile = | 262 TestingProfile* other_profile = |
263 testing_profile_manager()->CreateTestingProfile("other"); | 263 testing_profile_manager()->CreateTestingProfile("other"); |
264 other_profile->CreateBookmarkModel(true); | 264 other_profile->CreateBookmarkModel(true); |
265 | 265 |
266 BookmarkModel* bookmark_model = | 266 BookmarkModel* bookmark_model = |
267 BookmarkModelFactory::GetForProfile(profile()); | 267 BookmarkModelFactory::GetForBrowserContext(profile()); |
268 bookmarks::test::WaitForBookmarkModelToLoad(bookmark_model); | 268 bookmarks::test::WaitForBookmarkModelToLoad(bookmark_model); |
269 | 269 |
270 const BookmarkNode* node = | 270 const BookmarkNode* node = |
271 bookmark_model->AddURL(bookmark_model->bookmark_bar_node(), | 271 bookmark_model->AddURL(bookmark_model->bookmark_bar_node(), |
272 0, | 272 0, |
273 base::ASCIIToUTF16("Test Bookmark"), | 273 base::ASCIIToUTF16("Test Bookmark"), |
274 GURL("http://www.exmaple.com")); | 274 GURL("http://www.exmaple.com")); |
275 | 275 |
276 base::scoped_nsobject<BookmarkButtonCell> button_cell( | 276 base::scoped_nsobject<BookmarkButtonCell> button_cell( |
277 [[BookmarkButtonCell buttonCellForNode:node | 277 [[BookmarkButtonCell buttonCellForNode:node |
278 text:nil | 278 text:nil |
279 image:nil | 279 image:nil |
280 menuController:nil] retain]); | 280 menuController:nil] retain]); |
281 base::scoped_nsobject<BookmarkButton> dragged_button( | 281 base::scoped_nsobject<BookmarkButton> dragged_button( |
282 [[BookmarkButton alloc] init]); | 282 [[BookmarkButton alloc] init]); |
283 [dragged_button setCell:button_cell]; | 283 [dragged_button setCell:button_cell]; |
284 [info setDraggingSource:dragged_button.get()]; | 284 [info setDraggingSource:dragged_button.get()]; |
285 [info setDragDataType:ui::ClipboardUtil::UTIForPasteboardType( | 285 [info setDragDataType:ui::ClipboardUtil::UTIForPasteboardType( |
286 kBookmarkButtonDragType)]; | 286 kBookmarkButtonDragType)]; |
287 [info setButton:dragged_button.get()]; | 287 [info setButton:dragged_button.get()]; |
288 [info setBookmarkModel:BookmarkModelFactory::GetForProfile(other_profile)]; | 288 [info setBookmarkModel:BookmarkModelFactory::GetForBrowserContext( |
| 289 other_profile)]; |
289 EXPECT_EQ([view_ draggingEntered:(id)info.get()], NSDragOperationMove); | 290 EXPECT_EQ([view_ draggingEntered:(id)info.get()], NSDragOperationMove); |
290 EXPECT_TRUE([view_ performDragOperation:(id)info.get()]); | 291 EXPECT_TRUE([view_ performDragOperation:(id)info.get()]); |
291 EXPECT_TRUE([info dragButtonToPong]); | 292 EXPECT_TRUE([info dragButtonToPong]); |
292 EXPECT_TRUE([info dragButtonToShouldCopy]); | 293 EXPECT_TRUE([info dragButtonToShouldCopy]); |
293 EXPECT_FALSE([info dragURLsPong]); | 294 EXPECT_FALSE([info dragURLsPong]); |
294 EXPECT_TRUE([info dragBookmarkDataPong]); | 295 EXPECT_TRUE([info dragBookmarkDataPong]); |
295 } | 296 } |
296 | 297 |
297 TEST_F(BookmarkBarViewTest, URLDragAndDrop) { | 298 TEST_F(BookmarkBarViewTest, URLDragAndDrop) { |
298 base::scoped_nsobject<FakeBookmarkDraggingInfo> info( | 299 base::scoped_nsobject<FakeBookmarkDraggingInfo> info( |
(...skipping 29 matching lines...) Expand all Loading... |
328 EXPECT_TRUE([info draggingEnteredCalled]); // Ensure controller pinged. | 329 EXPECT_TRUE([info draggingEnteredCalled]); // Ensure controller pinged. |
329 EXPECT_TRUE([view_ dropIndicatorShown]); | 330 EXPECT_TRUE([view_ dropIndicatorShown]); |
330 EXPECT_EQ([view_ dropIndicatorPosition], kFakeIndicatorPos); | 331 EXPECT_EQ([view_ dropIndicatorPosition], kFakeIndicatorPos); |
331 | 332 |
332 [info setDropIndicatorShown:NO]; | 333 [info setDropIndicatorShown:NO]; |
333 EXPECT_EQ([view_ draggingEntered:(id)info.get()], NSDragOperationMove); | 334 EXPECT_EQ([view_ draggingEntered:(id)info.get()], NSDragOperationMove); |
334 EXPECT_FALSE([view_ dropIndicatorShown]); | 335 EXPECT_FALSE([view_ dropIndicatorShown]); |
335 } | 336 } |
336 | 337 |
337 } // namespace | 338 } // namespace |
OLD | NEW |