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

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

Issue 2216713002: Use BookmarkModelFactory::GetForBrowserContext everywhere (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@bookmarks
Patch Set: Replace in .mm files Created 4 years, 4 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
OLDNEW
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_folder_controller.h" 10 #import "chrome/browser/ui/cocoa/bookmarks/bookmark_bar_folder_controller.h"
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
60 const NSPoint kPoint = {10, 10}; 60 const NSPoint kPoint = {10, 10};
61 61
62 class BookmarkBarFolderViewTest : public CocoaProfileTest { 62 class BookmarkBarFolderViewTest : public CocoaProfileTest {
63 public: 63 public:
64 void SetUp() override { 64 void SetUp() override {
65 CocoaProfileTest::SetUp(); 65 CocoaProfileTest::SetUp();
66 66
67 view_.reset([[BookmarkBarFolderView alloc] init]); 67 view_.reset([[BookmarkBarFolderView alloc] init]);
68 68
69 mock_controller_.reset(GetMockController( 69 mock_controller_.reset(GetMockController(
70 YES, BookmarkModelFactory::GetForProfile(profile()))); 70 YES, BookmarkModelFactory::GetForBrowserContext(profile())));
71 71
72 mock_button_.reset(GetMockButton(mock_controller_.get())); 72 mock_button_.reset(GetMockButton(mock_controller_.get()));
73 [view_ awakeFromNib]; 73 [view_ awakeFromNib];
74 [view_ setController:mock_controller_]; 74 [view_ setController:mock_controller_];
75 } 75 }
76 76
77 void TearDown() override { 77 void TearDown() override {
78 [mock_controller_ verify]; 78 [mock_controller_ verify];
79 CocoaProfileTest::TearDown(); 79 CocoaProfileTest::TearDown();
80 } 80 }
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
122 [[[mock_controller stub] andReturnBool:show_indicator] 122 [[[mock_controller stub] andReturnBool:show_indicator]
123 shouldShowIndicatorShownForPoint:kPoint]; 123 shouldShowIndicatorShownForPoint:kPoint];
124 [[[mock_controller stub] andReturnCGFloat:kFakeIndicatorPos] 124 [[[mock_controller stub] andReturnCGFloat:kFakeIndicatorPos]
125 indicatorPosForDragToPoint:kPoint]; 125 indicatorPosForDragToPoint:kPoint];
126 [[[mock_controller stub] andReturnValue:OCMOCK_VALUE(model)] bookmarkModel]; 126 [[[mock_controller stub] andReturnValue:OCMOCK_VALUE(model)] bookmarkModel];
127 return [mock_controller retain]; 127 return [mock_controller retain];
128 } 128 }
129 129
130 id GetMockButton(id mock_controller) { 130 id GetMockButton(id mock_controller) {
131 BookmarkModel* bookmark_model = 131 BookmarkModel* bookmark_model =
132 BookmarkModelFactory::GetForProfile(profile()); 132 BookmarkModelFactory::GetForBrowserContext(profile());
133 const BookmarkNode* node = 133 const BookmarkNode* node =
134 bookmark_model->AddURL(bookmark_model->bookmark_bar_node(), 134 bookmark_model->AddURL(bookmark_model->bookmark_bar_node(),
135 0, 135 0,
136 base::ASCIIToUTF16("Test Bookmark"), 136 base::ASCIIToUTF16("Test Bookmark"),
137 GURL("http://www.exmaple.com")); 137 GURL("http://www.exmaple.com"));
138 138
139 id mock_button = [OCMockObject mockForClass:[BookmarkButton class]]; 139 id mock_button = [OCMockObject mockForClass:[BookmarkButton class]];
140 [[[mock_button stub] andReturnValue:OCMOCK_VALUE(node)] bookmarkNode]; 140 [[[mock_button stub] andReturnValue:OCMOCK_VALUE(node)] bookmarkNode];
141 return [mock_button retain]; 141 return [mock_button retain];
142 } 142 }
(...skipping 17 matching lines...) Expand all
160 EXPECT_TRUE([view_ performDragOperation:drag_info]); 160 EXPECT_TRUE([view_ performDragOperation:drag_info]);
161 } 161 }
162 162
163 // When dragging bookmarks across profiles, we should always copy, never move. 163 // When dragging bookmarks across profiles, we should always copy, never move.
164 TEST_F(BookmarkBarFolderViewTest, BookmarkButtonDragAndDropAcrossProfiles) { 164 TEST_F(BookmarkBarFolderViewTest, BookmarkButtonDragAndDropAcrossProfiles) {
165 // |other_profile| is owned by the |testing_profile_manager|. 165 // |other_profile| is owned by the |testing_profile_manager|.
166 TestingProfile* other_profile = 166 TestingProfile* other_profile =
167 testing_profile_manager()->CreateTestingProfile("other"); 167 testing_profile_manager()->CreateTestingProfile("other");
168 other_profile->CreateBookmarkModel(true); 168 other_profile->CreateBookmarkModel(true);
169 bookmarks::test::WaitForBookmarkModelToLoad( 169 bookmarks::test::WaitForBookmarkModelToLoad(
170 BookmarkModelFactory::GetForProfile(other_profile)); 170 BookmarkModelFactory::GetForBrowserContext(other_profile));
171 171
172 mock_controller_.reset(GetMockController( 172 mock_controller_.reset(GetMockController(
173 YES, BookmarkModelFactory::GetForProfile(other_profile))); 173 YES, BookmarkModelFactory::GetForBrowserContext(other_profile)));
174 [view_ setController:mock_controller_]; 174 [view_ setController:mock_controller_];
175 175
176 id drag_info = GetFakeDragInfoForType( 176 id drag_info = GetFakeDragInfoForType(
177 ui::ClipboardUtil::UTIForPasteboardType(kBookmarkButtonDragType)); 177 ui::ClipboardUtil::UTIForPasteboardType(kBookmarkButtonDragType));
178 [[[mock_controller_ expect] andReturnUnsignedInteger:NSDragOperationNone] 178 [[[mock_controller_ expect] andReturnUnsignedInteger:NSDragOperationNone]
179 draggingEntered:drag_info]; 179 draggingEntered:drag_info];
180 [[[mock_controller_ expect] andReturnBool:NO] dragBookmarkData:drag_info]; 180 [[[mock_controller_ expect] andReturnBool:NO] dragBookmarkData:drag_info];
181 [[[mock_controller_ expect] andReturnBool:YES] dragButton:OCMOCK_ANY 181 [[[mock_controller_ expect] andReturnBool:YES] dragButton:OCMOCK_ANY
182 to:kPoint 182 to:kPoint
183 copy:YES]; 183 copy:YES];
(...skipping 21 matching lines...) Expand all
205 TEST_F(BookmarkBarFolderViewTest, BookmarkButtonDropIndicator) { 205 TEST_F(BookmarkBarFolderViewTest, BookmarkButtonDropIndicator) {
206 id drag_info = GetFakeDragInfoForType( 206 id drag_info = GetFakeDragInfoForType(
207 ui::ClipboardUtil::UTIForPasteboardType(kBookmarkButtonDragType)); 207 ui::ClipboardUtil::UTIForPasteboardType(kBookmarkButtonDragType));
208 [[[mock_controller_ expect] andReturnUnsignedInteger:NSDragOperationNone] 208 [[[mock_controller_ expect] andReturnUnsignedInteger:NSDragOperationNone]
209 draggingEntered:drag_info]; 209 draggingEntered:drag_info];
210 EXPECT_EQ([view_ draggingEntered:drag_info], NSDragOperationMove); 210 EXPECT_EQ([view_ draggingEntered:drag_info], NSDragOperationMove);
211 [mock_controller_ verify]; 211 [mock_controller_ verify];
212 EXPECT_TRUE([view_ dropIndicatorShown]); 212 EXPECT_TRUE([view_ dropIndicatorShown]);
213 EXPECT_EQ([view_ dropIndicatorPosition], kFakeIndicatorPos); 213 EXPECT_EQ([view_ dropIndicatorPosition], kFakeIndicatorPos);
214 mock_controller_.reset(GetMockController( 214 mock_controller_.reset(GetMockController(
215 NO, BookmarkModelFactory::GetForProfile(profile()))); 215 NO, BookmarkModelFactory::GetForBrowserContext(profile())));
216 [view_ setController:mock_controller_]; 216 [view_ setController:mock_controller_];
217 [[[mock_controller_ expect] andReturnUnsignedInteger:NSDragOperationNone] 217 [[[mock_controller_ expect] andReturnUnsignedInteger:NSDragOperationNone]
218 draggingEntered:drag_info]; 218 draggingEntered:drag_info];
219 EXPECT_EQ([view_ draggingEntered:drag_info], NSDragOperationMove); 219 EXPECT_EQ([view_ draggingEntered:drag_info], NSDragOperationMove);
220 EXPECT_FALSE([view_ dropIndicatorShown]); 220 EXPECT_FALSE([view_ dropIndicatorShown]);
221 } 221 }
222 222
223 } // namespace 223 } // namespace
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698