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

Side by Side Diff: chrome/browser/ui/cocoa/bookmarks/bookmark_button_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/utf_string_conversions.h" 6 #include "base/strings/utf_string_conversions.h"
7 #include "chrome/browser/bookmarks/bookmark_model_factory.h" 7 #include "chrome/browser/bookmarks/bookmark_model_factory.h"
8 #import "chrome/browser/ui/cocoa/bookmarks/bookmark_button.h" 8 #import "chrome/browser/ui/cocoa/bookmarks/bookmark_button.h"
9 #import "chrome/browser/ui/cocoa/bookmarks/bookmark_button_cell.h" 9 #import "chrome/browser/ui/cocoa/bookmarks/bookmark_button_cell.h"
10 #include "chrome/browser/ui/cocoa/cocoa_profile_test.h" 10 #include "chrome/browser/ui/cocoa/cocoa_profile_test.h"
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after
84 84
85 EXPECT_TRUE([button isEmpty]); 85 EXPECT_TRUE([button isEmpty]);
86 EXPECT_FALSE([button isFolder]); 86 EXPECT_FALSE([button isFolder]);
87 EXPECT_FALSE([button bookmarkNode]); 87 EXPECT_FALSE([button bookmarkNode]);
88 88
89 NSEvent* downEvent = 89 NSEvent* downEvent =
90 cocoa_test_event_utils::LeftMouseDownAtPoint(NSMakePoint(10,10)); 90 cocoa_test_event_utils::LeftMouseDownAtPoint(NSMakePoint(10,10));
91 // Since this returns (does not actually begin a modal drag), success! 91 // Since this returns (does not actually begin a modal drag), success!
92 [button beginDrag:downEvent]; 92 [button beginDrag:downEvent];
93 93
94 BookmarkModel* model = BookmarkModelFactory::GetForProfile(profile()); 94 BookmarkModel* model = BookmarkModelFactory::GetForBrowserContext(profile());
95 const BookmarkNode* node = model->bookmark_bar_node(); 95 const BookmarkNode* node = model->bookmark_bar_node();
96 [cell setBookmarkNode:node]; 96 [cell setBookmarkNode:node];
97 EXPECT_FALSE([button isEmpty]); 97 EXPECT_FALSE([button isEmpty]);
98 EXPECT_TRUE([button isFolder]); 98 EXPECT_TRUE([button isFolder]);
99 EXPECT_EQ([button bookmarkNode], node); 99 EXPECT_EQ([button bookmarkNode], node);
100 100
101 node = model->AddURL(node, 0, base::ASCIIToUTF16("hi mom"), 101 node = model->AddURL(node, 0, base::ASCIIToUTF16("hi mom"),
102 GURL("http://www.google.com")); 102 GURL("http://www.google.com"));
103 [cell setBookmarkNode:node]; 103 [cell setBookmarkNode:node];
104 EXPECT_FALSE([button isEmpty]); 104 EXPECT_FALSE([button isEmpty]);
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
137 base::scoped_nsobject<BookmarkButton> button; 137 base::scoped_nsobject<BookmarkButton> button;
138 base::scoped_nsobject<BookmarkButtonCell> cell; 138 base::scoped_nsobject<BookmarkButtonCell> cell;
139 base::scoped_nsobject<FakeButtonDelegate> delegate( 139 base::scoped_nsobject<FakeButtonDelegate> delegate(
140 [[FakeButtonDelegate alloc] init]); 140 [[FakeButtonDelegate alloc] init]);
141 button.reset([[BookmarkButton alloc] initWithFrame:NSMakeRect(0,0,500,500)]); 141 button.reset([[BookmarkButton alloc] initWithFrame:NSMakeRect(0,0,500,500)]);
142 cell.reset([[BookmarkButtonCell alloc] initTextCell:@"hi mom"]); 142 cell.reset([[BookmarkButtonCell alloc] initTextCell:@"hi mom"]);
143 [button setCell:cell]; 143 [button setCell:cell];
144 [button setDelegate:delegate]; 144 [button setDelegate:delegate];
145 145
146 // Add a deletable bookmark to the button. 146 // Add a deletable bookmark to the button.
147 BookmarkModel* model = BookmarkModelFactory::GetForProfile(profile()); 147 BookmarkModel* model = BookmarkModelFactory::GetForBrowserContext(profile());
148 const BookmarkNode* barNode = model->bookmark_bar_node(); 148 const BookmarkNode* barNode = model->bookmark_bar_node();
149 const BookmarkNode* node = model->AddURL(barNode, 0, 149 const BookmarkNode* node = model->AddURL(barNode, 0,
150 base::ASCIIToUTF16("hi mom"), 150 base::ASCIIToUTF16("hi mom"),
151 GURL("http://www.google.com")); 151 GURL("http://www.google.com"));
152 [cell setBookmarkNode:node]; 152 [cell setBookmarkNode:node];
153 153
154 // Several calls to -draggingSession: coming up have nil arguments. Starting 154 // Several calls to -draggingSession: coming up have nil arguments. Starting
155 // with XCode7, that's not an option any more. Hotfixing for now. 155 // with XCode7, that's not an option any more. Hotfixing for now.
156 #pragma clang diagnostic push 156 #pragma clang diagnostic push
157 #pragma clang diagnostic ignored "-Wnonnull" 157 #pragma clang diagnostic ignored "-Wnonnull"
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
190 operation:NSDragOperationMove]; 190 operation:NSDragOperationMove];
191 EXPECT_EQ(0, delegate.get()->didDragToTrashCount_); 191 EXPECT_EQ(0, delegate.get()->didDragToTrashCount_);
192 [button draggingSession:nil 192 [button draggingSession:nil
193 endedAtPoint:NSZeroPoint 193 endedAtPoint:NSZeroPoint
194 operation:NSDragOperationDelete]; 194 operation:NSDragOperationDelete];
195 EXPECT_EQ(1, delegate.get()->didDragToTrashCount_); 195 EXPECT_EQ(1, delegate.get()->didDragToTrashCount_);
196 #pragma clang diagnostic pop 196 #pragma clang diagnostic pop
197 } 197 }
198 198
199 } 199 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698