| 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/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/bookmarks/bookmark_model_factory.h" |
| 10 #include "chrome/browser/profiles/profile.h" | 10 #include "chrome/browser/profiles/profile.h" |
| 11 #import "chrome/browser/ui/cocoa/bookmarks/bookmark_bar_folder_controller.h" | 11 #import "chrome/browser/ui/cocoa/bookmarks/bookmark_bar_folder_controller.h" |
| 12 #import "chrome/browser/ui/cocoa/bookmarks/bookmark_bar_folder_view.h" | 12 #import "chrome/browser/ui/cocoa/bookmarks/bookmark_bar_folder_view.h" |
| 13 #import "chrome/browser/ui/cocoa/bookmarks/bookmark_button.h" | 13 #import "chrome/browser/ui/cocoa/bookmarks/bookmark_button.h" |
| 14 #import "chrome/browser/ui/cocoa/bookmarks/bookmark_folder_target.h" | 14 #import "chrome/browser/ui/cocoa/bookmarks/bookmark_folder_target.h" |
| 15 #include "chrome/browser/ui/cocoa/cocoa_profile_test.h" | 15 #include "chrome/browser/ui/cocoa/cocoa_profile_test.h" |
| 16 #import "chrome/browser/ui/cocoa/cocoa_test_helper.h" | 16 #import "chrome/browser/ui/cocoa/cocoa_test_helper.h" |
| 17 #import "chrome/browser/ui/cocoa/url_drop_target.h" | 17 #import "chrome/browser/ui/cocoa/url_drop_target.h" |
| 18 #include "chrome/test/base/ui_test_utils.h" |
| 18 #include "testing/gtest/include/gtest/gtest.h" | 19 #include "testing/gtest/include/gtest/gtest.h" |
| 19 #include "testing/platform_test.h" | 20 #include "testing/platform_test.h" |
| 20 #import "third_party/mozilla/NSPasteboard+Utils.h" | 21 #import "third_party/mozilla/NSPasteboard+Utils.h" |
| 21 #import "third_party/ocmock/OCMock/OCMock.h" | 22 #import "third_party/ocmock/OCMock/OCMock.h" |
| 22 #import "third_party/ocmock/ocmock_extensions.h" | 23 #import "third_party/ocmock/ocmock_extensions.h" |
| 23 | 24 |
| 24 // Allows us to verify BookmarkBarFolderView. | 25 // Allows us to verify BookmarkBarFolderView. |
| 25 @interface BookmarkBarFolderView(TestingAPI) | 26 @interface BookmarkBarFolderView(TestingAPI) |
| 26 | 27 |
| 27 @property(readonly, nonatomic) BOOL dropIndicatorShown; | 28 @property(readonly, nonatomic) BOOL dropIndicatorShown; |
| (...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 149 EXPECT_EQ([view_ draggingEntered:drag_info], NSDragOperationMove); | 150 EXPECT_EQ([view_ draggingEntered:drag_info], NSDragOperationMove); |
| 150 EXPECT_TRUE([view_ performDragOperation:drag_info]); | 151 EXPECT_TRUE([view_ performDragOperation:drag_info]); |
| 151 } | 152 } |
| 152 | 153 |
| 153 // When dragging bookmarks across profiles, we should always copy, never move. | 154 // When dragging bookmarks across profiles, we should always copy, never move. |
| 154 TEST_F(BookmarkBarFolderViewTest, BookmarkButtonDragAndDropAcrossProfiles) { | 155 TEST_F(BookmarkBarFolderViewTest, BookmarkButtonDragAndDropAcrossProfiles) { |
| 155 // |other_profile| is owned by the |testing_profile_manager|. | 156 // |other_profile| is owned by the |testing_profile_manager|. |
| 156 TestingProfile* other_profile = | 157 TestingProfile* other_profile = |
| 157 testing_profile_manager()->CreateTestingProfile("other"); | 158 testing_profile_manager()->CreateTestingProfile("other"); |
| 158 other_profile->CreateBookmarkModel(true); | 159 other_profile->CreateBookmarkModel(true); |
| 159 other_profile->BlockUntilBookmarkModelLoaded(); | 160 ui_test_utils::WaitForBookmarkModelToLoad(other_profile); |
| 160 | 161 |
| 161 mock_controller_.reset(GetMockController( | 162 mock_controller_.reset(GetMockController( |
| 162 YES, BookmarkModelFactory::GetForProfile(other_profile))); | 163 YES, BookmarkModelFactory::GetForProfile(other_profile))); |
| 163 [view_ setController:mock_controller_]; | 164 [view_ setController:mock_controller_]; |
| 164 | 165 |
| 165 id drag_info = GetFakeDragInfoForType(kBookmarkButtonDragType); | 166 id drag_info = GetFakeDragInfoForType(kBookmarkButtonDragType); |
| 166 [[[mock_controller_ expect] andReturnUnsignedInteger:NSDragOperationNone] | 167 [[[mock_controller_ expect] andReturnUnsignedInteger:NSDragOperationNone] |
| 167 draggingEntered:drag_info]; | 168 draggingEntered:drag_info]; |
| 168 [[[mock_controller_ expect] andReturnBool:NO] dragBookmarkData:drag_info]; | 169 [[[mock_controller_ expect] andReturnBool:NO] dragBookmarkData:drag_info]; |
| 169 [[[mock_controller_ expect] andReturnBool:YES] dragButton:OCMOCK_ANY | 170 [[[mock_controller_ expect] andReturnBool:YES] dragButton:OCMOCK_ANY |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 201 mock_controller_.reset(GetMockController( | 202 mock_controller_.reset(GetMockController( |
| 202 NO, BookmarkModelFactory::GetForProfile(profile()))); | 203 NO, BookmarkModelFactory::GetForProfile(profile()))); |
| 203 [view_ setController:mock_controller_]; | 204 [view_ setController:mock_controller_]; |
| 204 [[[mock_controller_ expect] andReturnUnsignedInteger:NSDragOperationNone] | 205 [[[mock_controller_ expect] andReturnUnsignedInteger:NSDragOperationNone] |
| 205 draggingEntered:drag_info]; | 206 draggingEntered:drag_info]; |
| 206 EXPECT_EQ([view_ draggingEntered:drag_info], NSDragOperationMove); | 207 EXPECT_EQ([view_ draggingEntered:drag_info], NSDragOperationMove); |
| 207 EXPECT_FALSE([view_ dropIndicatorShown]); | 208 EXPECT_FALSE([view_ dropIndicatorShown]); |
| 208 } | 209 } |
| 209 | 210 |
| 210 } // namespace | 211 } // namespace |
| OLD | NEW |