OLD | NEW |
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 #include "base/string16.h" | 6 #include "base/string16.h" |
7 #include "base/utf_string_conversions.h" | 7 #include "base/utf_string_conversions.h" |
8 #include "chrome/browser/bookmarks/bookmark_model.h" | 8 #include "chrome/browser/bookmarks/bookmark_model.h" |
| 9 #include "chrome/browser/bookmarks/bookmark_model_factory.h" |
9 #include "chrome/browser/profiles/profile.h" | 10 #include "chrome/browser/profiles/profile.h" |
10 #import "chrome/browser/ui/cocoa/bookmarks/bookmark_bar_controller.h" | 11 #import "chrome/browser/ui/cocoa/bookmarks/bookmark_bar_controller.h" |
11 #import "chrome/browser/ui/cocoa/bookmarks/bookmark_bar_view.h" | 12 #import "chrome/browser/ui/cocoa/bookmarks/bookmark_bar_view.h" |
12 #import "chrome/browser/ui/cocoa/bookmarks/bookmark_button.h" | 13 #import "chrome/browser/ui/cocoa/bookmarks/bookmark_button.h" |
13 #import "chrome/browser/ui/cocoa/bookmarks/bookmark_button_cell.h" | 14 #import "chrome/browser/ui/cocoa/bookmarks/bookmark_button_cell.h" |
14 #import "chrome/browser/ui/cocoa/bookmarks/bookmark_folder_target.h" | 15 #import "chrome/browser/ui/cocoa/bookmarks/bookmark_folder_target.h" |
15 #include "chrome/browser/ui/cocoa/cocoa_profile_test.h" | 16 #include "chrome/browser/ui/cocoa/cocoa_profile_test.h" |
16 #import "chrome/browser/ui/cocoa/cocoa_test_helper.h" | 17 #import "chrome/browser/ui/cocoa/cocoa_test_helper.h" |
17 #import "chrome/browser/ui/cocoa/url_drop_target.h" | 18 #import "chrome/browser/ui/cocoa/url_drop_target.h" |
18 #include "testing/gtest/include/gtest/gtest.h" | 19 #include "testing/gtest/include/gtest/gtest.h" |
(...skipping 186 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
205 TEST_F(BookmarkBarViewTest, CanDragWindow) { | 206 TEST_F(BookmarkBarViewTest, CanDragWindow) { |
206 EXPECT_FALSE([view_ mouseDownCanMoveWindow]); | 207 EXPECT_FALSE([view_ mouseDownCanMoveWindow]); |
207 } | 208 } |
208 | 209 |
209 TEST_F(BookmarkBarViewTest, BookmarkButtonDragAndDrop) { | 210 TEST_F(BookmarkBarViewTest, BookmarkButtonDragAndDrop) { |
210 scoped_nsobject<FakeBookmarkDraggingInfo> | 211 scoped_nsobject<FakeBookmarkDraggingInfo> |
211 info([[FakeBookmarkDraggingInfo alloc] init]); | 212 info([[FakeBookmarkDraggingInfo alloc] init]); |
212 [view_ setController:info.get()]; | 213 [view_ setController:info.get()]; |
213 [info reset]; | 214 [info reset]; |
214 | 215 |
215 BookmarkModel* bookmark_model = profile()->GetBookmarkModel(); | 216 BookmarkModel* bookmark_model = |
| 217 BookmarkModelFactory::GetForProfile(profile()); |
216 const BookmarkNode* node = | 218 const BookmarkNode* node = |
217 bookmark_model->AddURL(bookmark_model->bookmark_bar_node(), | 219 bookmark_model->AddURL(bookmark_model->bookmark_bar_node(), |
218 0, | 220 0, |
219 ASCIIToUTF16("Test Bookmark"), | 221 ASCIIToUTF16("Test Bookmark"), |
220 GURL("http://www.exmaple.com")); | 222 GURL("http://www.exmaple.com")); |
221 | 223 |
222 scoped_nsobject<BookmarkButtonCell> button_cell( | 224 scoped_nsobject<BookmarkButtonCell> button_cell( |
223 [[BookmarkButtonCell buttonCellForNode:node | 225 [[BookmarkButtonCell buttonCellForNode:node |
224 contextMenu:nil | 226 contextMenu:nil |
225 cellText:nil | 227 cellText:nil |
(...skipping 18 matching lines...) Expand all Loading... |
244 info([[FakeBookmarkDraggingInfo alloc] init]); | 246 info([[FakeBookmarkDraggingInfo alloc] init]); |
245 [view_ setController:info.get()]; | 247 [view_ setController:info.get()]; |
246 [info reset]; | 248 [info reset]; |
247 | 249 |
248 // |other_profile| is owned by the |testing_profile_manager|. | 250 // |other_profile| is owned by the |testing_profile_manager|. |
249 TestingProfile* other_profile = | 251 TestingProfile* other_profile = |
250 testing_profile_manager()->CreateTestingProfile("other"); | 252 testing_profile_manager()->CreateTestingProfile("other"); |
251 other_profile->CreateBookmarkModel(true); | 253 other_profile->CreateBookmarkModel(true); |
252 other_profile->BlockUntilBookmarkModelLoaded(); | 254 other_profile->BlockUntilBookmarkModelLoaded(); |
253 | 255 |
254 BookmarkModel* bookmark_model = profile()->GetBookmarkModel(); | 256 BookmarkModel* bookmark_model = |
| 257 BookmarkModelFactory::GetForProfile(profile()); |
255 const BookmarkNode* node = | 258 const BookmarkNode* node = |
256 bookmark_model->AddURL(bookmark_model->bookmark_bar_node(), | 259 bookmark_model->AddURL(bookmark_model->bookmark_bar_node(), |
257 0, | 260 0, |
258 ASCIIToUTF16("Test Bookmark"), | 261 ASCIIToUTF16("Test Bookmark"), |
259 GURL("http://www.exmaple.com")); | 262 GURL("http://www.exmaple.com")); |
260 | 263 |
261 scoped_nsobject<BookmarkButtonCell> button_cell( | 264 scoped_nsobject<BookmarkButtonCell> button_cell( |
262 [[BookmarkButtonCell buttonCellForNode:node | 265 [[BookmarkButtonCell buttonCellForNode:node |
263 contextMenu:nil | 266 contextMenu:nil |
264 cellText:nil | 267 cellText:nil |
265 cellImage:nil] retain]); | 268 cellImage:nil] retain]); |
266 scoped_nsobject<BookmarkButton> dragged_button([[BookmarkButton alloc] init]); | 269 scoped_nsobject<BookmarkButton> dragged_button([[BookmarkButton alloc] init]); |
267 [dragged_button setCell:button_cell]; | 270 [dragged_button setCell:button_cell]; |
268 [info setDraggingSource:dragged_button.get()]; | 271 [info setDraggingSource:dragged_button.get()]; |
269 [info setDragDataType:kBookmarkButtonDragType]; | 272 [info setDragDataType:kBookmarkButtonDragType]; |
270 [info setButton:dragged_button.get()]; | 273 [info setButton:dragged_button.get()]; |
271 [info setBookmarkModel:other_profile->GetBookmarkModel()]; | 274 [info setBookmarkModel:BookmarkModelFactory::GetForProfile(other_profile)]; |
272 EXPECT_EQ([view_ draggingEntered:(id)info.get()], NSDragOperationMove); | 275 EXPECT_EQ([view_ draggingEntered:(id)info.get()], NSDragOperationMove); |
273 EXPECT_TRUE([view_ performDragOperation:(id)info.get()]); | 276 EXPECT_TRUE([view_ performDragOperation:(id)info.get()]); |
274 EXPECT_TRUE([info dragButtonToPong]); | 277 EXPECT_TRUE([info dragButtonToPong]); |
275 EXPECT_TRUE([info dragButtonToShouldCopy]); | 278 EXPECT_TRUE([info dragButtonToShouldCopy]); |
276 EXPECT_FALSE([info dragURLsPong]); | 279 EXPECT_FALSE([info dragURLsPong]); |
277 EXPECT_TRUE([info dragBookmarkDataPong]); | 280 EXPECT_TRUE([info dragBookmarkDataPong]); |
278 } | 281 } |
279 | 282 |
280 TEST_F(BookmarkBarViewTest, URLDragAndDrop) { | 283 TEST_F(BookmarkBarViewTest, URLDragAndDrop) { |
281 scoped_nsobject<FakeBookmarkDraggingInfo> | 284 scoped_nsobject<FakeBookmarkDraggingInfo> |
(...skipping 27 matching lines...) Expand all Loading... |
309 EXPECT_TRUE([info draggingEnteredCalled]); // Ensure controller pinged. | 312 EXPECT_TRUE([info draggingEnteredCalled]); // Ensure controller pinged. |
310 EXPECT_TRUE([view_ dropIndicatorShown]); | 313 EXPECT_TRUE([view_ dropIndicatorShown]); |
311 EXPECT_EQ([view_ dropIndicatorPosition], kFakeIndicatorPos); | 314 EXPECT_EQ([view_ dropIndicatorPosition], kFakeIndicatorPos); |
312 | 315 |
313 [info setDropIndicatorShown:NO]; | 316 [info setDropIndicatorShown:NO]; |
314 EXPECT_EQ([view_ draggingEntered:(id)info.get()], NSDragOperationMove); | 317 EXPECT_EQ([view_ draggingEntered:(id)info.get()], NSDragOperationMove); |
315 EXPECT_FALSE([view_ dropIndicatorShown]); | 318 EXPECT_FALSE([view_ dropIndicatorShown]); |
316 } | 319 } |
317 | 320 |
318 } // namespace | 321 } // namespace |
OLD | NEW |