Index: chrome/browser/ui/cocoa/bookmarks/bookmark_bar_controller_unittest.mm |
=================================================================== |
--- chrome/browser/ui/cocoa/bookmarks/bookmark_bar_controller_unittest.mm (revision 149630) |
+++ chrome/browser/ui/cocoa/bookmarks/bookmark_bar_controller_unittest.mm (working copy) |
@@ -12,6 +12,7 @@ |
#include "base/sys_string_conversions.h" |
#include "base/utf_string_conversions.h" |
#include "chrome/browser/bookmarks/bookmark_model.h" |
+#include "chrome/browser/bookmarks/bookmark_model_factory.h" |
#include "chrome/browser/bookmarks/bookmark_utils.h" |
#include "chrome/browser/extensions/test_extension_system.h" |
#import "chrome/browser/ui/cocoa/animation_utils.h" |
@@ -341,7 +342,7 @@ |
// Return a menu item that points to the given URL. |
NSMenuItem* ItemForBookmarkBarMenu(GURL& gurl) { |
- BookmarkModel* model = profile()->GetBookmarkModel(); |
+ BookmarkModel* model = BookmarkModelFactory::GetForProfile(profile()); |
const BookmarkNode* parent = model->bookmark_bar_node(); |
const BookmarkNode* node = model->AddURL(parent, parent->child_count(), |
ASCIIToUTF16("A title"), gurl); |
@@ -529,7 +530,7 @@ |
// Confirm our "no items" container goes away when we add the 1st |
// bookmark, and comes back when we delete the bookmark. |
TEST_F(BookmarkBarControllerTest, NoItemContainerGoesAway) { |
- BookmarkModel* model = profile()->GetBookmarkModel(); |
+ BookmarkModel* model = BookmarkModelFactory::GetForProfile(profile()); |
const BookmarkNode* bar = model->bookmark_bar_node(); |
[bar_ loaded:model]; |
@@ -562,7 +563,7 @@ |
// Confirm off the side button only enabled when reasonable. |
TEST_F(BookmarkBarControllerTest, OffTheSideButtonHidden) { |
- BookmarkModel* model = profile()->GetBookmarkModel(); |
+ BookmarkModel* model = BookmarkModelFactory::GetForProfile(profile()); |
[bar_ setIgnoreAnimations:YES]; |
[bar_ loaded:model]; |
@@ -612,7 +613,7 @@ |
// off-the-side menu while it is open. This test tries to bang hard |
// in this area to reproduce the crash. |
TEST_F(BookmarkBarControllerTest, DeleteFromOffTheSideWhileItIsOpen) { |
- BookmarkModel* model = profile()->GetBookmarkModel(); |
+ BookmarkModel* model = BookmarkModelFactory::GetForProfile(profile()); |
[bar_ setIgnoreAnimations:YES]; |
[bar_ loaded:model]; |
@@ -703,7 +704,7 @@ |
} |
TEST_F(BookmarkBarControllerTest, MenuForFolderNode) { |
- BookmarkModel* model = profile()->GetBookmarkModel(); |
+ BookmarkModel* model = BookmarkModelFactory::GetForProfile(profile()); |
// First make sure something (e.g. "(empty)" string) is always present. |
NSMenu* menu = [bar_ menuForFolderNode:model->bookmark_bar_node()]; |
@@ -788,7 +789,7 @@ |
} |
TEST_F(BookmarkBarControllerTest, TestAddRemoveAndClear) { |
- BookmarkModel* model = profile()->GetBookmarkModel(); |
+ BookmarkModel* model = BookmarkModelFactory::GetForProfile(profile()); |
NSView* buttonView = [bar_ buttonView]; |
EXPECT_EQ(0U, [[bar_ buttons] count]); |
unsigned int initial_subview_count = [[buttonView subviews] count]; |
@@ -838,7 +839,7 @@ |
// Make sure we don't create too many buttons; we only really need |
// ones that will be visible. |
TEST_F(BookmarkBarControllerTest, TestButtonLimits) { |
- BookmarkModel* model = profile()->GetBookmarkModel(); |
+ BookmarkModel* model = BookmarkModelFactory::GetForProfile(profile()); |
EXPECT_EQ(0U, [[bar_ buttons] count]); |
// Add one; make sure we see it. |
const BookmarkNode* parent = model->bookmark_bar_node(); |
@@ -898,7 +899,7 @@ |
TEST_F(BookmarkBarControllerTest, CheckForGrowth) { |
WithNoAnimation at_all; // Turn off Cocoa auto animation in this scope. |
- BookmarkModel* model = profile()->GetBookmarkModel(); |
+ BookmarkModel* model = BookmarkModelFactory::GetForProfile(profile()); |
GURL gurl1("http://www.google.com"); |
string16 title1(ASCIIToUTF16("x")); |
bookmark_utils::AddIfNotBookmarked(model, gurl1, title1); |
@@ -925,7 +926,7 @@ |
} |
TEST_F(BookmarkBarControllerTest, DeleteBookmark) { |
- BookmarkModel* model = profile()->GetBookmarkModel(); |
+ BookmarkModel* model = BookmarkModelFactory::GetForProfile(profile()); |
const char* urls[] = { "https://secret.url.com", |
"http://super.duper.web.site.for.doodz.gov", |
@@ -950,7 +951,7 @@ |
// checkForBookmarkButtonGrowth:. |
TEST_F(BookmarkBarControllerTest, Cell) { |
- BookmarkModel* model = profile()->GetBookmarkModel(); |
+ BookmarkModel* model = BookmarkModelFactory::GetForProfile(profile()); |
[bar_ loaded:model]; |
const BookmarkNode* parent = model->bookmark_bar_node(); |
@@ -981,7 +982,7 @@ |
// Test that middle clicking on a bookmark button results in an open action. |
TEST_F(BookmarkBarControllerTest, MiddleClick) { |
- BookmarkModel* model = profile()->GetBookmarkModel(); |
+ BookmarkModel* model = BookmarkModelFactory::GetForProfile(profile()); |
GURL gurl1("http://www.google.com/"); |
string16 title1(ASCIIToUTF16("x")); |
bookmark_utils::AddIfNotBookmarked(model, gurl1, title1); |
@@ -996,13 +997,13 @@ |
} |
TEST_F(BookmarkBarControllerTest, DisplaysHelpMessageOnEmpty) { |
- BookmarkModel* model = profile()->GetBookmarkModel(); |
+ BookmarkModel* model = BookmarkModelFactory::GetForProfile(profile()); |
[bar_ loaded:model]; |
EXPECT_FALSE([[[bar_ buttonView] noItemContainer] isHidden]); |
} |
TEST_F(BookmarkBarControllerTest, HidesHelpMessageWithBookmark) { |
- BookmarkModel* model = profile()->GetBookmarkModel(); |
+ BookmarkModel* model = BookmarkModelFactory::GetForProfile(profile()); |
const BookmarkNode* parent = model->bookmark_bar_node(); |
model->AddURL(parent, parent->child_count(), |
@@ -1013,7 +1014,7 @@ |
} |
TEST_F(BookmarkBarControllerTest, BookmarkButtonSizing) { |
- BookmarkModel* model = profile()->GetBookmarkModel(); |
+ BookmarkModel* model = BookmarkModelFactory::GetForProfile(profile()); |
const BookmarkNode* parent = model->bookmark_bar_node(); |
model->AddURL(parent, parent->child_count(), |
@@ -1054,7 +1055,7 @@ |
[nstitles addObject:base::SysUTF8ToNSString(titles[i])]; |
} |
- BookmarkModel* model = profile()->GetBookmarkModel(); |
+ BookmarkModel* model = BookmarkModelFactory::GetForProfile(profile()); |
const BookmarkNode* parent = model->bookmark_bar_node(); |
[bar_ addURLs:nsurls withTitles:nstitles at:NSZeroPoint]; |
EXPECT_EQ(4, parent->child_count()); |
@@ -1074,7 +1075,7 @@ |
} |
TEST_F(BookmarkBarControllerTest, TestButtonOrBar) { |
- BookmarkModel* model = profile()->GetBookmarkModel(); |
+ BookmarkModel* model = BookmarkModelFactory::GetForProfile(profile()); |
GURL gurl1("http://www.google.com"); |
string16 title1(ASCIIToUTF16("x")); |
bookmark_utils::AddIfNotBookmarked(model, gurl1, title1); |
@@ -1104,7 +1105,7 @@ |
} |
TEST_F(BookmarkBarControllerTest, TestMenuNodeAndDisable) { |
- BookmarkModel* model = profile()->GetBookmarkModel(); |
+ BookmarkModel* model = BookmarkModelFactory::GetForProfile(profile()); |
const BookmarkNode* parent = model->bookmark_bar_node(); |
const BookmarkNode* folder = model->AddFolder(parent, |
parent->child_count(), |
@@ -1132,7 +1133,7 @@ |
TEST_F(BookmarkBarControllerTest, TestDragButton) { |
WithNoAnimation at_all; |
- BookmarkModel* model = profile()->GetBookmarkModel(); |
+ BookmarkModel* model = BookmarkModelFactory::GetForProfile(profile()); |
GURL gurls[] = { GURL("http://www.google.com/a"), |
GURL("http://www.google.com/b"), |
@@ -1203,7 +1204,7 @@ |
} |
TEST_F(BookmarkBarControllerTest, TestCopyButton) { |
- BookmarkModel* model = profile()->GetBookmarkModel(); |
+ BookmarkModel* model = BookmarkModelFactory::GetForProfile(profile()); |
GURL gurls[] = { GURL("http://www.google.com/a"), |
GURL("http://www.google.com/b"), |
@@ -1233,7 +1234,7 @@ |
// Fake a theme with colored text. Apply it and make sure bookmark |
// buttons have the same colored text. Repeat more than once. |
TEST_F(BookmarkBarControllerTest, TestThemedButton) { |
- BookmarkModel* model = profile()->GetBookmarkModel(); |
+ BookmarkModel* model = BookmarkModelFactory::GetForProfile(profile()); |
bookmark_utils::AddIfNotBookmarked( |
model, GURL("http://www.foo.com"), ASCIIToUTF16("small")); |
BookmarkButton* button = [[bar_ buttons] objectAtIndex:0]; |
@@ -1259,7 +1260,7 @@ |
// Test that delegates and targets of buttons are cleared on dealloc. |
TEST_F(BookmarkBarControllerTest, TestClearOnDealloc) { |
// Make some bookmark buttons. |
- BookmarkModel* model = profile()->GetBookmarkModel(); |
+ BookmarkModel* model = BookmarkModelFactory::GetForProfile(profile()); |
GURL gurls[] = { GURL("http://www.foo.com/"), |
GURL("http://www.bar.com/"), |
GURL("http://www.baz.com/") }; |
@@ -1293,7 +1294,7 @@ |
} |
TEST_F(BookmarkBarControllerTest, TestFolders) { |
- BookmarkModel* model = profile()->GetBookmarkModel(); |
+ BookmarkModel* model = BookmarkModelFactory::GetForProfile(profile()); |
// Create some folder buttons. |
const BookmarkNode* parent = model->bookmark_bar_node(); |
@@ -1337,7 +1338,7 @@ |
// click on a folder folder menus should show until another click on a folder |
// button, and a click outside the bar and its folder menus. |
TEST_F(BookmarkBarControllerTest, TestFolderButtons) { |
- BookmarkModel& model(*profile()->GetBookmarkModel()); |
+ BookmarkModel& model(*BookmarkModelFactory::GetForProfile(profile())); |
const BookmarkNode* root = model.bookmark_bar_node(); |
const std::string model_string("1b 2f:[ 2f1b 2f2b ] 3b 4f:[ 4f1b 4f2b ] "); |
model_test_utils::AddNodesFromModelString(model, root, model_string); |
@@ -1401,7 +1402,7 @@ |
EXPECT_TRUE([bar_ offTheSideButtonIsHidden]); |
// Create some buttons. |
- BookmarkModel* model = profile()->GetBookmarkModel(); |
+ BookmarkModel* model = BookmarkModelFactory::GetForProfile(profile()); |
const BookmarkNode* parent = model->bookmark_bar_node(); |
for (int x = 0; x < 30; x++) { |
model->AddURL(parent, parent->child_count(), |
@@ -1480,7 +1481,7 @@ |
TEST_F(BookmarkBarControllerTest, DropDestination) { |
// Make some buttons. |
- BookmarkModel* model = profile()->GetBookmarkModel(); |
+ BookmarkModel* model = BookmarkModelFactory::GetForProfile(profile()); |
const BookmarkNode* parent = model->bookmark_bar_node(); |
model->AddFolder(parent, parent->child_count(), ASCIIToUTF16("folder 1")); |
model->AddFolder(parent, parent->child_count(), ASCIIToUTF16("folder 2")); |
@@ -1518,7 +1519,7 @@ |
} |
TEST_F(BookmarkBarControllerTest, NodeDeletedWhileMenuIsOpen) { |
- BookmarkModel* model = profile()->GetBookmarkModel(); |
+ BookmarkModel* model = BookmarkModelFactory::GetForProfile(profile()); |
[bar_ loaded:model]; |
const BookmarkNode* parent = model->bookmark_bar_node(); |
@@ -1557,7 +1558,7 @@ |
} |
TEST_F(BookmarkBarControllerTest, NodeDeletedWhileContextMenuIsOpen) { |
- BookmarkModel* model = profile()->GetBookmarkModel(); |
+ BookmarkModel* model = BookmarkModelFactory::GetForProfile(profile()); |
[bar_ loaded:model]; |
const BookmarkNode* parent = model->bookmark_bar_node(); |
@@ -1583,7 +1584,7 @@ |
} |
TEST_F(BookmarkBarControllerTest, CloseFolderOnAnimate) { |
- BookmarkModel* model = profile()->GetBookmarkModel(); |
+ BookmarkModel* model = BookmarkModelFactory::GetForProfile(profile()); |
const BookmarkNode* parent = model->bookmark_bar_node(); |
const BookmarkNode* folder = model->AddFolder(parent, |
parent->child_count(), |
@@ -1616,7 +1617,7 @@ |
} |
TEST_F(BookmarkBarControllerTest, MoveRemoveAddButtons) { |
- BookmarkModel& model(*profile()->GetBookmarkModel()); |
+ BookmarkModel& model(*BookmarkModelFactory::GetForProfile(profile())); |
const BookmarkNode* root = model.bookmark_bar_node(); |
const std::string model_string("1b 2f:[ 2f1b 2f2b ] 3b "); |
model_test_utils::AddNodesFromModelString(model, root, model_string); |
@@ -1709,7 +1710,7 @@ |
frame.origin.y = 100; |
[[[bar_ view] superview] setFrame:frame]; |
- BookmarkModel* model = profile()->GetBookmarkModel(); |
+ BookmarkModel* model = BookmarkModelFactory::GetForProfile(profile()); |
parent_ = model->bookmark_bar_node(); |
// { one, { two-one, two-two }, three } |
model->AddURL(parent_, parent_->child_count(), ASCIIToUTF16("title"), |
@@ -1877,7 +1878,7 @@ |
}; |
TEST_F(BookmarkBarControllerDragDropTest, DragMoveBarBookmarkToOffTheSide) { |
- BookmarkModel& model(*profile()->GetBookmarkModel()); |
+ BookmarkModel& model(*BookmarkModelFactory::GetForProfile(profile())); |
const BookmarkNode* root = model.bookmark_bar_node(); |
const std::string model_string("1bWithLongName 2fWithLongName:[ " |
"2f1bWithLongName 2f2fWithLongName:[ 2f2f1bWithLongName " |
@@ -1929,7 +1930,7 @@ |
} |
TEST_F(BookmarkBarControllerDragDropTest, DragOffTheSideToOther) { |
- BookmarkModel& model(*profile()->GetBookmarkModel()); |
+ BookmarkModel& model(*BookmarkModelFactory::GetForProfile(profile())); |
const BookmarkNode* root = model.bookmark_bar_node(); |
const std::string model_string("1bWithLongName 2bWithLongName " |
"3bWithLongName 4bWithLongName 5bWithLongName 6bWithLongName " |
@@ -1986,7 +1987,7 @@ |
} |
TEST_F(BookmarkBarControllerDragDropTest, DragBookmarkData) { |
- BookmarkModel& model(*profile()->GetBookmarkModel()); |
+ BookmarkModel& model(*BookmarkModelFactory::GetForProfile(profile())); |
const BookmarkNode* root = model.bookmark_bar_node(); |
const std::string model_string("1b 2f:[ 2f1b 2f2f:[ 2f2f1b 2f2f2b 2f2f3b ] " |
"2f3b ] 3b 4b "); |
@@ -2046,7 +2047,7 @@ |
} |
TEST_F(BookmarkBarControllerDragDropTest, AddURLs) { |
- BookmarkModel& model(*profile()->GetBookmarkModel()); |
+ BookmarkModel& model(*BookmarkModelFactory::GetForProfile(profile())); |
const BookmarkNode* root = model.bookmark_bar_node(); |
const std::string model_string("1b 2f:[ 2f1b 2f2f:[ 2f2f1b 2f2f2b 2f2f3b ] " |
"2f3b ] 3b 4b "); |
@@ -2078,7 +2079,7 @@ |
} |
TEST_F(BookmarkBarControllerDragDropTest, ControllerForNode) { |
- BookmarkModel& model(*profile()->GetBookmarkModel()); |
+ BookmarkModel& model(*BookmarkModelFactory::GetForProfile(profile())); |
const BookmarkNode* root = model.bookmark_bar_node(); |
const std::string model_string("1b 2f:[ 2f1b 2f2b ] 3b "); |
model_test_utils::AddNodesFromModelString(model, root, model_string); |
@@ -2094,7 +2095,7 @@ |
} |
TEST_F(BookmarkBarControllerDragDropTest, DropPositionIndicator) { |
- BookmarkModel& model(*profile()->GetBookmarkModel()); |
+ BookmarkModel& model(*BookmarkModelFactory::GetForProfile(profile())); |
const BookmarkNode* root = model.bookmark_bar_node(); |
const std::string model_string("1b 2f:[ 2f1b 2f2b 2f3b ] 3b 4b "); |
model_test_utils::AddNodesFromModelString(model, root, model_string); |
@@ -2126,7 +2127,7 @@ |
} |
TEST_F(BookmarkBarControllerDragDropTest, PulseButton) { |
- BookmarkModel* model = profile()->GetBookmarkModel(); |
+ BookmarkModel* model = BookmarkModelFactory::GetForProfile(profile()); |
const BookmarkNode* root = model->bookmark_bar_node(); |
GURL gurl("http://www.google.com"); |
const BookmarkNode* node = model->AddURL(root, root->child_count(), |
@@ -2161,7 +2162,7 @@ |
} |
TEST_F(BookmarkBarControllerDragDropTest, DragBookmarkDataToTrash) { |
- BookmarkModel& model(*profile()->GetBookmarkModel()); |
+ BookmarkModel& model(*BookmarkModelFactory::GetForProfile(profile())); |
const BookmarkNode* root = model.bookmark_bar_node(); |
const std::string model_string("1b 2f:[ 2f1b 2f2f:[ 2f2f1b 2f2f2b 2f2f3b ] " |
"2f3b ] 3b 4b "); |