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 <cmath> | 5 #include <cmath> |
6 | 6 |
7 #include "base/mac/scoped_nsobject.h" | 7 #include "base/mac/scoped_nsobject.h" |
8 #include "base/strings/utf_string_conversions.h" | 8 #include "base/strings/utf_string_conversions.h" |
9 #include "chrome/browser/bookmarks/bookmark_model_factory.h" | 9 #include "chrome/browser/bookmarks/bookmark_model_factory.h" |
10 #import "chrome/browser/ui/cocoa/bookmarks/bookmark_bar_constants.h" | 10 #import "chrome/browser/ui/cocoa/bookmarks/bookmark_bar_constants.h" |
(...skipping 18 matching lines...) Expand all Loading... |
29 using bookmarks::BookmarkNode; | 29 using bookmarks::BookmarkNode; |
30 | 30 |
31 namespace { | 31 namespace { |
32 | 32 |
33 const int kLotsOfNodesCount = 150; | 33 const int kLotsOfNodesCount = 150; |
34 | 34 |
35 // Deletes the bookmark corresponding to |button|. | 35 // Deletes the bookmark corresponding to |button|. |
36 void DeleteBookmark(BookmarkButton* button, Profile* profile) { | 36 void DeleteBookmark(BookmarkButton* button, Profile* profile) { |
37 const BookmarkNode* node = [button bookmarkNode]; | 37 const BookmarkNode* node = [button bookmarkNode]; |
38 if (node) { | 38 if (node) { |
39 BookmarkModel* model = BookmarkModelFactory::GetForProfile(profile); | 39 BookmarkModel* model = BookmarkModelFactory::GetForBrowserContext(profile); |
40 model->Remove(node); | 40 model->Remove(node); |
41 } | 41 } |
42 } | 42 } |
43 | 43 |
44 } // namespace | 44 } // namespace |
45 | 45 |
46 // Add a redirect to make testing easier. | 46 // Add a redirect to make testing easier. |
47 @interface BookmarkBarFolderController(MakeTestingEasier) | 47 @interface BookmarkBarFolderController(MakeTestingEasier) |
48 - (void)validateMenuSpacing; | 48 - (void)validateMenuSpacing; |
49 @end | 49 @end |
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
140 const BookmarkNode* longTitleNode_; // Owned by model. | 140 const BookmarkNode* longTitleNode_; // Owned by model. |
141 | 141 |
142 void SetUp() override { | 142 void SetUp() override { |
143 CocoaProfileTest::SetUp(); | 143 CocoaProfileTest::SetUp(); |
144 ASSERT_TRUE(profile()); | 144 ASSERT_TRUE(profile()); |
145 | 145 |
146 CreateModel(); | 146 CreateModel(); |
147 } | 147 } |
148 | 148 |
149 void CreateModel() { | 149 void CreateModel() { |
150 BookmarkModel* model = BookmarkModelFactory::GetForProfile(profile()); | 150 BookmarkModel* model = |
| 151 BookmarkModelFactory::GetForBrowserContext(profile()); |
151 const BookmarkNode* parent = model->bookmark_bar_node(); | 152 const BookmarkNode* parent = model->bookmark_bar_node(); |
152 const BookmarkNode* folderA = model->AddFolder(parent, | 153 const BookmarkNode* folderA = model->AddFolder(parent, |
153 parent->child_count(), | 154 parent->child_count(), |
154 ASCIIToUTF16("folder")); | 155 ASCIIToUTF16("folder")); |
155 folderA_ = folderA; | 156 folderA_ = folderA; |
156 model->AddFolder(parent, parent->child_count(), | 157 model->AddFolder(parent, parent->child_count(), |
157 ASCIIToUTF16("sibbling folder")); | 158 ASCIIToUTF16("sibbling folder")); |
158 const BookmarkNode* folderB = model->AddFolder(folderA, | 159 const BookmarkNode* folderB = model->AddFolder(folderA, |
159 folderA->child_count(), | 160 folderA->child_count(), |
160 ASCIIToUTF16("subfolder 1")); | 161 ASCIIToUTF16("subfolder 1")); |
(...skipping 21 matching lines...) Expand all Loading... |
182 frame.size.width, chrome::kNTPBookmarkBarHeight); | 183 frame.size.width, chrome::kNTPBookmarkBarHeight); |
183 NSView* fakeToolbarView = [[[NSView alloc] initWithFrame:frame] | 184 NSView* fakeToolbarView = [[[NSView alloc] initWithFrame:frame] |
184 autorelease]; | 185 autorelease]; |
185 [[test_window() contentView] addSubview:fakeToolbarView]; | 186 [[test_window() contentView] addSubview:fakeToolbarView]; |
186 [fakeToolbarView addSubview:[bar_ view]]; | 187 [fakeToolbarView addSubview:[bar_ view]]; |
187 [bar_ setBookmarkBarEnabled:YES]; | 188 [bar_ setBookmarkBarEnabled:YES]; |
188 } | 189 } |
189 | 190 |
190 // Remove the bookmark with the long title. | 191 // Remove the bookmark with the long title. |
191 void RemoveLongTitleNode() { | 192 void RemoveLongTitleNode() { |
192 BookmarkModel* model = BookmarkModelFactory::GetForProfile(profile()); | 193 BookmarkModel* model = |
| 194 BookmarkModelFactory::GetForBrowserContext(profile()); |
193 model->Remove(longTitleNode_); | 195 model->Remove(longTitleNode_); |
194 } | 196 } |
195 | 197 |
196 // Add LOTS of nodes to our model if needed (e.g. scrolling). | 198 // Add LOTS of nodes to our model if needed (e.g. scrolling). |
197 // Returns the number of nodes added. | 199 // Returns the number of nodes added. |
198 int AddLotsOfNodes() { | 200 int AddLotsOfNodes() { |
199 BookmarkModel* model = BookmarkModelFactory::GetForProfile(profile()); | 201 BookmarkModel* model = |
| 202 BookmarkModelFactory::GetForBrowserContext(profile()); |
200 for (int i = 0; i < kLotsOfNodesCount; i++) { | 203 for (int i = 0; i < kLotsOfNodesCount; i++) { |
201 model->AddURL(folderA_, folderA_->child_count(), | 204 model->AddURL(folderA_, folderA_->child_count(), |
202 ASCIIToUTF16("repeated title"), | 205 ASCIIToUTF16("repeated title"), |
203 GURL("http://www.google.com/repeated/url")); | 206 GURL("http://www.google.com/repeated/url")); |
204 } | 207 } |
205 return kLotsOfNodesCount; | 208 return kLotsOfNodesCount; |
206 } | 209 } |
207 | 210 |
208 // Return a simple BookmarkBarFolderController. | 211 // Return a simple BookmarkBarFolderController. |
209 BookmarkBarFolderControllerPong* SimpleBookmarkBarFolderController() { | 212 BookmarkBarFolderControllerPong* SimpleBookmarkBarFolderController() { |
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
291 [bbfc2 window]; | 294 [bbfc2 window]; |
292 pt = [bbfc2 windowTopLeftForWidth:0 height:100]; | 295 pt = [bbfc2 windowTopLeftForWidth:0 height:100]; |
293 // We're now overlapping the window a bit. | 296 // We're now overlapping the window a bit. |
294 EXPECT_EQ(pt.x, NSMaxX([[bbfc.get() window] frame]) - | 297 EXPECT_EQ(pt.x, NSMaxX([[bbfc.get() window] frame]) - |
295 bookmarks::kBookmarkMenuOverlap); | 298 bookmarks::kBookmarkMenuOverlap); |
296 } | 299 } |
297 | 300 |
298 // Confirm we grow right until end of screen, then start growing left | 301 // Confirm we grow right until end of screen, then start growing left |
299 // until end of screen again, then right. | 302 // until end of screen again, then right. |
300 TEST_F(BookmarkBarFolderControllerTest, PositionRightLeftRight) { | 303 TEST_F(BookmarkBarFolderControllerTest, PositionRightLeftRight) { |
301 BookmarkModel* model = BookmarkModelFactory::GetForProfile(profile()); | 304 BookmarkModel* model = BookmarkModelFactory::GetForBrowserContext(profile()); |
302 const BookmarkNode* parent = model->bookmark_bar_node(); | 305 const BookmarkNode* parent = model->bookmark_bar_node(); |
303 const BookmarkNode* folder = parent; | 306 const BookmarkNode* folder = parent; |
304 | 307 |
305 const int count = 100; | 308 const int count = 100; |
306 int i; | 309 int i; |
307 // Make some super duper deeply nested folders. | 310 // Make some super duper deeply nested folders. |
308 for (i = 0; i < count; i++) { | 311 for (i = 0; i < count; i++) { |
309 folder = model->AddFolder(folder, 0, ASCIIToUTF16("nested folder")); | 312 folder = model->AddFolder(folder, 0, ASCIIToUTF16("nested folder")); |
310 } | 313 } |
311 | 314 |
(...skipping 428 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
740 [[test_window() contentView] addSubview:parent_view_]; | 743 [[test_window() contentView] addSubview:parent_view_]; |
741 | 744 |
742 // Make sure it's open so certain things aren't no-ops. | 745 // Make sure it's open so certain things aren't no-ops. |
743 [bar updateState:BookmarkBar::SHOW | 746 [bar updateState:BookmarkBar::SHOW |
744 changeType:BookmarkBar::DONT_ANIMATE_STATE_CHANGE]; | 747 changeType:BookmarkBar::DONT_ANIMATE_STATE_CHANGE]; |
745 } | 748 } |
746 }; | 749 }; |
747 | 750 |
748 TEST_F(BookmarkBarFolderControllerMenuTest, DragMoveBarBookmarkToFolder) { | 751 TEST_F(BookmarkBarFolderControllerMenuTest, DragMoveBarBookmarkToFolder) { |
749 WithNoAnimation at_all; | 752 WithNoAnimation at_all; |
750 BookmarkModel* model = BookmarkModelFactory::GetForProfile(profile()); | 753 BookmarkModel* model = BookmarkModelFactory::GetForBrowserContext(profile()); |
751 const BookmarkNode* root = model->bookmark_bar_node(); | 754 const BookmarkNode* root = model->bookmark_bar_node(); |
752 const std::string model_string("1b 2f:[ 2f1b 2f2f:[ 2f2f1b 2f2f2b " | 755 const std::string model_string("1b 2f:[ 2f1b 2f2f:[ 2f2f1b 2f2f2b " |
753 "2f2f3b ] 2f3b ] 3b 4f:[ 4f1f:[ 4f1f1b 4f1f2b 4f1f3b ] 4f2f:[ 4f2f1b " | 756 "2f2f3b ] 2f3b ] 3b 4f:[ 4f1f:[ 4f1f1b 4f1f2b 4f1f3b ] 4f2f:[ 4f2f1b " |
754 "4f2f2b 4f2f3b ] 4f3f:[ 4f3f1b 4f3f2b 4f3f3b ] ] 5b "); | 757 "4f2f2b 4f2f3b ] 4f3f:[ 4f3f1b 4f3f2b 4f3f3b ] ] 5b "); |
755 bookmarks::test::AddNodesFromModelString(model, root, model_string); | 758 bookmarks::test::AddNodesFromModelString(model, root, model_string); |
756 | 759 |
757 // Validate initial model. | 760 // Validate initial model. |
758 std::string actualModelString = bookmarks::test::ModelStringFromNode(root); | 761 std::string actualModelString = bookmarks::test::ModelStringFromNode(root); |
759 EXPECT_EQ(model_string, actualModelString); | 762 EXPECT_EQ(model_string, actualModelString); |
760 | 763 |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
813 targetButton = [bar_ buttonWithTitleEqualTo:@"2f"]; | 816 targetButton = [bar_ buttonWithTitleEqualTo:@"2f"]; |
814 ASSERT_TRUE(targetButton); | 817 ASSERT_TRUE(targetButton); |
815 [bar_ dragButton:draggedButton | 818 [bar_ dragButton:draggedButton |
816 to:[targetButton left] | 819 to:[targetButton left] |
817 copy:NO]; | 820 copy:NO]; |
818 EXPECT_EQ(model_string, bookmarks::test::ModelStringFromNode(root)); | 821 EXPECT_EQ(model_string, bookmarks::test::ModelStringFromNode(root)); |
819 // Don't check the folder window since it's not supposed to be showing. | 822 // Don't check the folder window since it's not supposed to be showing. |
820 } | 823 } |
821 | 824 |
822 TEST_F(BookmarkBarFolderControllerMenuTest, DragCopyBarBookmarkToFolder) { | 825 TEST_F(BookmarkBarFolderControllerMenuTest, DragCopyBarBookmarkToFolder) { |
823 BookmarkModel* model = BookmarkModelFactory::GetForProfile(profile()); | 826 BookmarkModel* model = BookmarkModelFactory::GetForBrowserContext(profile()); |
824 const BookmarkNode* root = model->bookmark_bar_node(); | 827 const BookmarkNode* root = model->bookmark_bar_node(); |
825 const std::string model_string("1b 2f:[ 2f1b 2f2f:[ 2f2f1b 2f2f2b " | 828 const std::string model_string("1b 2f:[ 2f1b 2f2f:[ 2f2f1b 2f2f2b " |
826 "2f2f3b ] 2f3b ] 3b 4f:[ 4f1f:[ 4f1f1b 4f1f2b 4f1f3b ] 4f2f:[ 4f2f1b " | 829 "2f2f3b ] 2f3b ] 3b 4f:[ 4f1f:[ 4f1f1b 4f1f2b 4f1f3b ] 4f2f:[ 4f2f1b " |
827 "4f2f2b 4f2f3b ] 4f3f:[ 4f3f1b 4f3f2b 4f3f3b ] ] 5b "); | 830 "4f2f2b 4f2f3b ] 4f3f:[ 4f3f1b 4f3f2b 4f3f3b ] ] 5b "); |
828 bookmarks::test::AddNodesFromModelString(model, root, model_string); | 831 bookmarks::test::AddNodesFromModelString(model, root, model_string); |
829 | 832 |
830 // Validate initial model. | 833 // Validate initial model. |
831 std::string actualModelString = bookmarks::test::ModelStringFromNode(root); | 834 std::string actualModelString = bookmarks::test::ModelStringFromNode(root); |
832 EXPECT_EQ(model_string, actualModelString); | 835 EXPECT_EQ(model_string, actualModelString); |
833 | 836 |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
877 [bar_ dragButton:draggedButton | 880 [bar_ dragButton:draggedButton |
878 to:[targetButton left] | 881 to:[targetButton left] |
879 copy:YES]; | 882 copy:YES]; |
880 const std::string expected_2("1b 2f:[ 2f1b 1b 2f2f:[ 2f2f1b " | 883 const std::string expected_2("1b 2f:[ 2f1b 1b 2f2f:[ 2f2f1b " |
881 "2f2f2b 2f2f3b ] 2f3b ] 3b 1b 4f:[ 4f1f:[ 4f1f1b 4f1f2b 4f1f3b ] 4f2f:[ " | 884 "2f2f2b 2f2f3b ] 2f3b ] 3b 1b 4f:[ 4f1f:[ 4f1f1b 4f1f2b 4f1f3b ] 4f2f:[ " |
882 "4f2f1b 4f2f2b 4f2f3b ] 4f3f:[ 4f3f1b 4f3f2b 4f3f3b ] ] 5b "); | 885 "4f2f1b 4f2f2b 4f2f3b ] 4f3f:[ 4f3f1b 4f3f2b 4f3f3b ] ] 5b "); |
883 EXPECT_EQ(expected_2, bookmarks::test::ModelStringFromNode(root)); | 886 EXPECT_EQ(expected_2, bookmarks::test::ModelStringFromNode(root)); |
884 } | 887 } |
885 | 888 |
886 TEST_F(BookmarkBarFolderControllerMenuTest, DragMoveBarBookmarkToSubfolder) { | 889 TEST_F(BookmarkBarFolderControllerMenuTest, DragMoveBarBookmarkToSubfolder) { |
887 BookmarkModel* model = BookmarkModelFactory::GetForProfile(profile()); | 890 BookmarkModel* model = BookmarkModelFactory::GetForBrowserContext(profile()); |
888 const BookmarkNode* root = model->bookmark_bar_node(); | 891 const BookmarkNode* root = model->bookmark_bar_node(); |
889 const std::string model_string("1b 2f:[ 2f1b 2f2f:[ 2f2f1b 2f2f2b " | 892 const std::string model_string("1b 2f:[ 2f1b 2f2f:[ 2f2f1b 2f2f2b " |
890 "2f2f3b ] 2f3b ] 3b 4f:[ 4f1f:[ 4f1f1b 4f1f2b 4f1f3b ] 4f2f:[ 4f2f1b " | 893 "2f2f3b ] 2f3b ] 3b 4f:[ 4f1f:[ 4f1f1b 4f1f2b 4f1f3b ] 4f2f:[ 4f2f1b " |
891 "4f2f2b 4f2f3b ] 4f3f:[ 4f3f1b 4f3f2b 4f3f3b ] ] 5b "); | 894 "4f2f2b 4f2f3b ] 4f3f:[ 4f3f1b 4f3f2b 4f3f3b ] ] 5b "); |
892 bookmarks::test::AddNodesFromModelString(model, root, model_string); | 895 bookmarks::test::AddNodesFromModelString(model, root, model_string); |
893 | 896 |
894 // Validate initial model. | 897 // Validate initial model. |
895 std::string actualModelString = bookmarks::test::ModelStringFromNode(root); | 898 std::string actualModelString = bookmarks::test::ModelStringFromNode(root); |
896 EXPECT_EQ(model_string, actualModelString); | 899 EXPECT_EQ(model_string, actualModelString); |
897 | 900 |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
942 EXPECT_NSRECT_EQ(oldToWindowFrame, newToWindowFrame); | 945 EXPECT_NSRECT_EQ(oldToWindowFrame, newToWindowFrame); |
943 NSRect newToSubwindowFrame = [toSubwindow frame]; | 946 NSRect newToSubwindowFrame = [toSubwindow frame]; |
944 NSRect expectedToSubwindowFrame = oldToSubwindowFrame; | 947 NSRect expectedToSubwindowFrame = oldToSubwindowFrame; |
945 expectedToSubwindowFrame.origin.y -= bookmarks::kBookmarkFolderButtonHeight; | 948 expectedToSubwindowFrame.origin.y -= bookmarks::kBookmarkFolderButtonHeight; |
946 expectedToSubwindowFrame.size.height += | 949 expectedToSubwindowFrame.size.height += |
947 bookmarks::kBookmarkFolderButtonHeight; | 950 bookmarks::kBookmarkFolderButtonHeight; |
948 EXPECT_NSRECT_EQ(expectedToSubwindowFrame, newToSubwindowFrame); | 951 EXPECT_NSRECT_EQ(expectedToSubwindowFrame, newToSubwindowFrame); |
949 } | 952 } |
950 | 953 |
951 TEST_F(BookmarkBarFolderControllerMenuTest, DragMoveWithinFolder) { | 954 TEST_F(BookmarkBarFolderControllerMenuTest, DragMoveWithinFolder) { |
952 BookmarkModel* model = BookmarkModelFactory::GetForProfile(profile()); | 955 BookmarkModel* model = BookmarkModelFactory::GetForBrowserContext(profile()); |
953 const BookmarkNode* root = model->bookmark_bar_node(); | 956 const BookmarkNode* root = model->bookmark_bar_node(); |
954 const std::string model_string("1b 2f:[ 2f1b 2f2f:[ 2f2f1b 2f2f2b " | 957 const std::string model_string("1b 2f:[ 2f1b 2f2f:[ 2f2f1b 2f2f2b " |
955 "2f2f3b ] 2f3b ] 3b 4f:[ 4f1f:[ 4f1f1b 4f1f2b 4f1f3b ] 4f2f:[ 4f2f1b " | 958 "2f2f3b ] 2f3b ] 3b 4f:[ 4f1f:[ 4f1f1b 4f1f2b 4f1f3b ] 4f2f:[ 4f2f1b " |
956 "4f2f2b 4f2f3b ] 4f3f:[ 4f3f1b 4f3f2b 4f3f3b ] ] 5b "); | 959 "4f2f2b 4f2f3b ] 4f3f:[ 4f3f1b 4f3f2b 4f3f3b ] ] 5b "); |
957 bookmarks::test::AddNodesFromModelString(model, root, model_string); | 960 bookmarks::test::AddNodesFromModelString(model, root, model_string); |
958 | 961 |
959 // Validate initial model. | 962 // Validate initial model. |
960 std::string actualModelString = bookmarks::test::ModelStringFromNode(root); | 963 std::string actualModelString = bookmarks::test::ModelStringFromNode(root); |
961 EXPECT_EQ(model_string, actualModelString); | 964 EXPECT_EQ(model_string, actualModelString); |
962 | 965 |
(...skipping 28 matching lines...) Expand all Loading... |
991 | 994 |
992 // The folder window should not have changed. | 995 // The folder window should not have changed. |
993 NSRect newToWindowFrame = [toWindow frame]; | 996 NSRect newToWindowFrame = [toWindow frame]; |
994 EXPECT_NSRECT_EQ(oldToWindowFrame, newToWindowFrame); | 997 EXPECT_NSRECT_EQ(oldToWindowFrame, newToWindowFrame); |
995 | 998 |
996 // Check button spacing. | 999 // Check button spacing. |
997 [folderController validateMenuSpacing]; | 1000 [folderController validateMenuSpacing]; |
998 } | 1001 } |
999 | 1002 |
1000 TEST_F(BookmarkBarFolderControllerMenuTest, DragParentOntoChild) { | 1003 TEST_F(BookmarkBarFolderControllerMenuTest, DragParentOntoChild) { |
1001 BookmarkModel* model = BookmarkModelFactory::GetForProfile(profile()); | 1004 BookmarkModel* model = BookmarkModelFactory::GetForBrowserContext(profile()); |
1002 const BookmarkNode* root = model->bookmark_bar_node(); | 1005 const BookmarkNode* root = model->bookmark_bar_node(); |
1003 const std::string model_string("1b 2f:[ 2f1b 2f2f:[ 2f2f1b 2f2f2b " | 1006 const std::string model_string("1b 2f:[ 2f1b 2f2f:[ 2f2f1b 2f2f2b " |
1004 "2f2f3b ] 2f3b ] 3b 4f:[ 4f1f:[ 4f1f1b 4f1f2b 4f1f3b ] 4f2f:[ 4f2f1b " | 1007 "2f2f3b ] 2f3b ] 3b 4f:[ 4f1f:[ 4f1f1b 4f1f2b 4f1f3b ] 4f2f:[ 4f2f1b " |
1005 "4f2f2b 4f2f3b ] 4f3f:[ 4f3f1b 4f3f2b 4f3f3b ] ] 5b "); | 1008 "4f2f2b 4f2f3b ] 4f3f:[ 4f3f1b 4f3f2b 4f3f3b ] ] 5b "); |
1006 bookmarks::test::AddNodesFromModelString(model, root, model_string); | 1009 bookmarks::test::AddNodesFromModelString(model, root, model_string); |
1007 | 1010 |
1008 // Validate initial model. | 1011 // Validate initial model. |
1009 std::string actualModelString = bookmarks::test::ModelStringFromNode(root); | 1012 std::string actualModelString = bookmarks::test::ModelStringFromNode(root); |
1010 EXPECT_EQ(model_string, actualModelString); | 1013 EXPECT_EQ(model_string, actualModelString); |
1011 | 1014 |
(...skipping 16 matching lines...) Expand all Loading... |
1028 to:[targetButton top] | 1031 to:[targetButton top] |
1029 copy:NO]; | 1032 copy:NO]; |
1030 // The model should not have changed. | 1033 // The model should not have changed. |
1031 EXPECT_EQ(model_string, bookmarks::test::ModelStringFromNode(root)); | 1034 EXPECT_EQ(model_string, bookmarks::test::ModelStringFromNode(root)); |
1032 | 1035 |
1033 // Check button spacing. | 1036 // Check button spacing. |
1034 [folderController validateMenuSpacing]; | 1037 [folderController validateMenuSpacing]; |
1035 } | 1038 } |
1036 | 1039 |
1037 TEST_F(BookmarkBarFolderControllerMenuTest, DragMoveChildToParent) { | 1040 TEST_F(BookmarkBarFolderControllerMenuTest, DragMoveChildToParent) { |
1038 BookmarkModel* model = BookmarkModelFactory::GetForProfile(profile()); | 1041 BookmarkModel* model = BookmarkModelFactory::GetForBrowserContext(profile()); |
1039 const BookmarkNode* root = model->bookmark_bar_node(); | 1042 const BookmarkNode* root = model->bookmark_bar_node(); |
1040 const std::string model_string("1b 2f:[ 2f1b 2f2f:[ 2f2f1b 2f2f2b " | 1043 const std::string model_string("1b 2f:[ 2f1b 2f2f:[ 2f2f1b 2f2f2b " |
1041 "2f2f3b ] 2f3b ] 3b 4f:[ 4f1f:[ 4f1f1b 4f1f2b 4f1f3b ] 4f2f:[ 4f2f1b " | 1044 "2f2f3b ] 2f3b ] 3b 4f:[ 4f1f:[ 4f1f1b 4f1f2b 4f1f3b ] 4f2f:[ 4f2f1b " |
1042 "4f2f2b 4f2f3b ] 4f3f:[ 4f3f1b 4f3f2b 4f3f3b ] ] 5b "); | 1045 "4f2f2b 4f2f3b ] 4f3f:[ 4f3f1b 4f3f2b 4f3f3b ] ] 5b "); |
1043 bookmarks::test::AddNodesFromModelString(model, root, model_string); | 1046 bookmarks::test::AddNodesFromModelString(model, root, model_string); |
1044 | 1047 |
1045 // Validate initial model. | 1048 // Validate initial model. |
1046 std::string actualModelString = bookmarks::test::ModelStringFromNode(root); | 1049 std::string actualModelString = bookmarks::test::ModelStringFromNode(root); |
1047 EXPECT_EQ(model_string, actualModelString); | 1050 EXPECT_EQ(model_string, actualModelString); |
1048 | 1051 |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1080 | 1083 |
1081 // Check button spacing. | 1084 // Check button spacing. |
1082 [folderController validateMenuSpacing]; | 1085 [folderController validateMenuSpacing]; |
1083 // The window should not have gone away. | 1086 // The window should not have gone away. |
1084 EXPECT_TRUE([bar_ folderController]); | 1087 EXPECT_TRUE([bar_ folderController]); |
1085 // The subfolder should have gone away. | 1088 // The subfolder should have gone away. |
1086 EXPECT_FALSE([folderController folderController]); | 1089 EXPECT_FALSE([folderController folderController]); |
1087 } | 1090 } |
1088 | 1091 |
1089 TEST_F(BookmarkBarFolderControllerMenuTest, DragWindowResizing) { | 1092 TEST_F(BookmarkBarFolderControllerMenuTest, DragWindowResizing) { |
1090 BookmarkModel* model = BookmarkModelFactory::GetForProfile(profile()); | 1093 BookmarkModel* model = BookmarkModelFactory::GetForBrowserContext(profile()); |
1091 const BookmarkNode* root = model->bookmark_bar_node(); | 1094 const BookmarkNode* root = model->bookmark_bar_node(); |
1092 const std::string model_string( | 1095 const std::string model_string( |
1093 "a b:[ b1 b2 b3 ] reallyReallyLongBookmarkName c "); | 1096 "a b:[ b1 b2 b3 ] reallyReallyLongBookmarkName c "); |
1094 bookmarks::test::AddNodesFromModelString(model, root, model_string); | 1097 bookmarks::test::AddNodesFromModelString(model, root, model_string); |
1095 | 1098 |
1096 // Validate initial model. | 1099 // Validate initial model. |
1097 std::string actualModelString = bookmarks::test::ModelStringFromNode(root); | 1100 std::string actualModelString = bookmarks::test::ModelStringFromNode(root); |
1098 EXPECT_EQ(model_string, actualModelString); | 1101 EXPECT_EQ(model_string, actualModelString); |
1099 | 1102 |
1100 // Pop up a folder menu. | 1103 // Pop up a folder menu. |
(...skipping 19 matching lines...) Expand all Loading... |
1120 // Verify the model change. | 1123 // Verify the model change. |
1121 const std::string expected_string( | 1124 const std::string expected_string( |
1122 "a b:[ b1 reallyReallyLongBookmarkName b2 b3 ] c "); | 1125 "a b:[ b1 reallyReallyLongBookmarkName b2 b3 ] c "); |
1123 EXPECT_EQ(expected_string, bookmarks::test::ModelStringFromNode(root)); | 1126 EXPECT_EQ(expected_string, bookmarks::test::ModelStringFromNode(root)); |
1124 // Verify the window grew. Just test a reasonable width gain. | 1127 // Verify the window grew. Just test a reasonable width gain. |
1125 CGFloat newWidth = NSWidth([toWindow frame]); | 1128 CGFloat newWidth = NSWidth([toWindow frame]); |
1126 EXPECT_LT(oldWidth + 30.0, newWidth); | 1129 EXPECT_LT(oldWidth + 30.0, newWidth); |
1127 } | 1130 } |
1128 | 1131 |
1129 TEST_F(BookmarkBarFolderControllerMenuTest, MoveRemoveAddButtons) { | 1132 TEST_F(BookmarkBarFolderControllerMenuTest, MoveRemoveAddButtons) { |
1130 BookmarkModel* model = BookmarkModelFactory::GetForProfile(profile()); | 1133 BookmarkModel* model = BookmarkModelFactory::GetForBrowserContext(profile()); |
1131 const BookmarkNode* root = model->bookmark_bar_node(); | 1134 const BookmarkNode* root = model->bookmark_bar_node(); |
1132 const std::string model_string("1b 2f:[ 2f1b 2f2b 2f3b ] 3b 4b "); | 1135 const std::string model_string("1b 2f:[ 2f1b 2f2b 2f3b ] 3b 4b "); |
1133 bookmarks::test::AddNodesFromModelString(model, root, model_string); | 1136 bookmarks::test::AddNodesFromModelString(model, root, model_string); |
1134 | 1137 |
1135 // Validate initial model. | 1138 // Validate initial model. |
1136 std::string actualModelString = bookmarks::test::ModelStringFromNode(root); | 1139 std::string actualModelString = bookmarks::test::ModelStringFromNode(root); |
1137 EXPECT_EQ(model_string, actualModelString); | 1140 EXPECT_EQ(model_string, actualModelString); |
1138 | 1141 |
1139 // Pop up a folder menu. | 1142 // Pop up a folder menu. |
1140 BookmarkButton* toFolder = [bar_ buttonWithTitleEqualTo:@"2f"]; | 1143 BookmarkButton* toFolder = [bar_ buttonWithTitleEqualTo:@"2f"]; |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1183 EXPECT_NSEQ(@"3b", [[buttons objectAtIndex:0] title]); | 1186 EXPECT_NSEQ(@"3b", [[buttons objectAtIndex:0] title]); |
1184 EXPECT_NSEQ(@"2f2b", [[buttons objectAtIndex:1] title]); | 1187 EXPECT_NSEQ(@"2f2b", [[buttons objectAtIndex:1] title]); |
1185 EXPECT_NSEQ(@"2f3b", [[buttons objectAtIndex:2] title]); | 1188 EXPECT_NSEQ(@"2f3b", [[buttons objectAtIndex:2] title]); |
1186 EXPECT_EQ(oldDisplayedButtons, [buttons count]); | 1189 EXPECT_EQ(oldDisplayedButtons, [buttons count]); |
1187 | 1190 |
1188 // Check button spacing. | 1191 // Check button spacing. |
1189 [folder validateMenuSpacing]; | 1192 [folder validateMenuSpacing]; |
1190 } | 1193 } |
1191 | 1194 |
1192 TEST_F(BookmarkBarFolderControllerMenuTest, RemoveLastButtonOtherBookmarks) { | 1195 TEST_F(BookmarkBarFolderControllerMenuTest, RemoveLastButtonOtherBookmarks) { |
1193 BookmarkModel* model = BookmarkModelFactory::GetForProfile(profile()); | 1196 BookmarkModel* model = BookmarkModelFactory::GetForBrowserContext(profile()); |
1194 const BookmarkNode* otherBookmarks = model->other_node(); | 1197 const BookmarkNode* otherBookmarks = model->other_node(); |
1195 | 1198 |
1196 BookmarkButton* otherButton = [bar_ otherBookmarksButton]; | 1199 BookmarkButton* otherButton = [bar_ otherBookmarksButton]; |
1197 ASSERT_TRUE(otherButton); | 1200 ASSERT_TRUE(otherButton); |
1198 | 1201 |
1199 // Open the folder to get the folderController_. | 1202 // Open the folder to get the folderController_. |
1200 [[otherButton target] openBookmarkFolderFromButton:otherButton]; | 1203 [[otherButton target] openBookmarkFolderFromButton:otherButton]; |
1201 BookmarkBarFolderController* folder = [bar_ folderController]; | 1204 BookmarkBarFolderController* folder = [bar_ folderController]; |
1202 EXPECT_TRUE(folder); | 1205 EXPECT_TRUE(folder); |
1203 | 1206 |
(...skipping 16 matching lines...) Expand all Loading... |
1220 // is hidden. | 1223 // is hidden. |
1221 [folder removeButton:0 animate:NO]; | 1224 [folder removeButton:0 animate:NO]; |
1222 EXPECT_EQ(0U, [buttons count]); | 1225 EXPECT_EQ(0U, [buttons count]); |
1223 | 1226 |
1224 // 'Other bookmarks' folder gets closed once we remove the last button. Hence | 1227 // 'Other bookmarks' folder gets closed once we remove the last button. Hence |
1225 // folderController_ should be NULL. | 1228 // folderController_ should be NULL. |
1226 EXPECT_FALSE([bar_ folderController]); | 1229 EXPECT_FALSE([bar_ folderController]); |
1227 } | 1230 } |
1228 | 1231 |
1229 TEST_F(BookmarkBarFolderControllerMenuTest, ControllerForNode) { | 1232 TEST_F(BookmarkBarFolderControllerMenuTest, ControllerForNode) { |
1230 BookmarkModel* model = BookmarkModelFactory::GetForProfile(profile()); | 1233 BookmarkModel* model = BookmarkModelFactory::GetForBrowserContext(profile()); |
1231 const BookmarkNode* root = model->bookmark_bar_node(); | 1234 const BookmarkNode* root = model->bookmark_bar_node(); |
1232 const std::string model_string("1b 2f:[ 2f1b 2f2b ] 3b "); | 1235 const std::string model_string("1b 2f:[ 2f1b 2f2b ] 3b "); |
1233 bookmarks::test::AddNodesFromModelString(model, root, model_string); | 1236 bookmarks::test::AddNodesFromModelString(model, root, model_string); |
1234 | 1237 |
1235 // Validate initial model. | 1238 // Validate initial model. |
1236 std::string actualModelString = bookmarks::test::ModelStringFromNode(root); | 1239 std::string actualModelString = bookmarks::test::ModelStringFromNode(root); |
1237 EXPECT_EQ(model_string, actualModelString); | 1240 EXPECT_EQ(model_string, actualModelString); |
1238 | 1241 |
1239 // Find the main bar controller. | 1242 // Find the main bar controller. |
1240 const void* expectedController = bar_; | 1243 const void* expectedController = bar_; |
(...skipping 14 matching lines...) Expand all Loading... |
1255 expectedController = folder; | 1258 expectedController = folder; |
1256 actualController = [bar_ controllerForNode:targetNode]; | 1259 actualController = [bar_ controllerForNode:targetNode]; |
1257 EXPECT_EQ(expectedController, actualController); | 1260 EXPECT_EQ(expectedController, actualController); |
1258 | 1261 |
1259 // Find the folder controller from the bar. | 1262 // Find the folder controller from the bar. |
1260 actualController = [folder controllerForNode:targetNode]; | 1263 actualController = [folder controllerForNode:targetNode]; |
1261 EXPECT_EQ(expectedController, actualController); | 1264 EXPECT_EQ(expectedController, actualController); |
1262 } | 1265 } |
1263 | 1266 |
1264 TEST_F(BookmarkBarFolderControllerMenuTest, MenuSizingAndScrollArrows) { | 1267 TEST_F(BookmarkBarFolderControllerMenuTest, MenuSizingAndScrollArrows) { |
1265 BookmarkModel* model = BookmarkModelFactory::GetForProfile(profile()); | 1268 BookmarkModel* model = BookmarkModelFactory::GetForBrowserContext(profile()); |
1266 const BookmarkNode* root = model->bookmark_bar_node(); | 1269 const BookmarkNode* root = model->bookmark_bar_node(); |
1267 const std::string model_string("1b 2b 3b "); | 1270 const std::string model_string("1b 2b 3b "); |
1268 bookmarks::test::AddNodesFromModelString(model, root, model_string); | 1271 bookmarks::test::AddNodesFromModelString(model, root, model_string); |
1269 | 1272 |
1270 // Validate initial model. | 1273 // Validate initial model. |
1271 std::string actualModelString = bookmarks::test::ModelStringFromNode(root); | 1274 std::string actualModelString = bookmarks::test::ModelStringFromNode(root); |
1272 EXPECT_EQ(model_string, actualModelString); | 1275 EXPECT_EQ(model_string, actualModelString); |
1273 | 1276 |
1274 const BookmarkNode* parent = model->bookmark_bar_node(); | 1277 const BookmarkNode* parent = model->bookmark_bar_node(); |
1275 const BookmarkNode* folder = model->AddFolder(parent, | 1278 const BookmarkNode* folder = model->AddFolder(parent, |
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1352 // Check the size. It should have reduced. | 1355 // Check the size. It should have reduced. |
1353 EXPECT_GT(scrollerWidth, NSWidth([folderView frame])); | 1356 EXPECT_GT(scrollerWidth, NSWidth([folderView frame])); |
1354 EXPECT_GT(buttonWidth, NSWidth([button frame])); | 1357 EXPECT_GT(buttonWidth, NSWidth([button frame])); |
1355 | 1358 |
1356 // Check button spacing. | 1359 // Check button spacing. |
1357 [folderController validateMenuSpacing]; | 1360 [folderController validateMenuSpacing]; |
1358 } | 1361 } |
1359 | 1362 |
1360 // See http://crbug.com/46101 | 1363 // See http://crbug.com/46101 |
1361 TEST_F(BookmarkBarFolderControllerMenuTest, HoverThenDeleteBookmark) { | 1364 TEST_F(BookmarkBarFolderControllerMenuTest, HoverThenDeleteBookmark) { |
1362 BookmarkModel* model = BookmarkModelFactory::GetForProfile(profile()); | 1365 BookmarkModel* model = BookmarkModelFactory::GetForBrowserContext(profile()); |
1363 const BookmarkNode* root = model->bookmark_bar_node(); | 1366 const BookmarkNode* root = model->bookmark_bar_node(); |
1364 const BookmarkNode* folder = model->AddFolder(root, | 1367 const BookmarkNode* folder = model->AddFolder(root, |
1365 root->child_count(), | 1368 root->child_count(), |
1366 ASCIIToUTF16("BIG")); | 1369 ASCIIToUTF16("BIG")); |
1367 for (int i = 0; i < kLotsOfNodesCount; i++) | 1370 for (int i = 0; i < kLotsOfNodesCount; i++) |
1368 model->AddURL(folder, folder->child_count(), ASCIIToUTF16("kid"), | 1371 model->AddURL(folder, folder->child_count(), ASCIIToUTF16("kid"), |
1369 GURL("http://kid.com/smile")); | 1372 GURL("http://kid.com/smile")); |
1370 | 1373 |
1371 // Pop open the new folder window and hover one of its kids. | 1374 // Pop open the new folder window and hover one of its kids. |
1372 BookmarkButton* button = [bar_ buttonWithTitleEqualTo:@"BIG"]; | 1375 BookmarkButton* button = [bar_ buttonWithTitleEqualTo:@"BIG"]; |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1420 std::vector<const BookmarkNode*> dragDataNodes; | 1423 std::vector<const BookmarkNode*> dragDataNodes; |
1421 if(dragDataNode_) { | 1424 if(dragDataNode_) { |
1422 dragDataNodes.push_back(dragDataNode_); | 1425 dragDataNodes.push_back(dragDataNode_); |
1423 } | 1426 } |
1424 return dragDataNodes; | 1427 return dragDataNodes; |
1425 } | 1428 } |
1426 | 1429 |
1427 @end | 1430 @end |
1428 | 1431 |
1429 TEST_F(BookmarkBarFolderControllerMenuTest, DragBookmarkData) { | 1432 TEST_F(BookmarkBarFolderControllerMenuTest, DragBookmarkData) { |
1430 BookmarkModel* model = BookmarkModelFactory::GetForProfile(profile()); | 1433 BookmarkModel* model = BookmarkModelFactory::GetForBrowserContext(profile()); |
1431 const BookmarkNode* root = model->bookmark_bar_node(); | 1434 const BookmarkNode* root = model->bookmark_bar_node(); |
1432 const std::string model_string("1b 2f:[ 2f1b 2f2f:[ 2f2f1b 2f2f2b 2f2f3b ] " | 1435 const std::string model_string("1b 2f:[ 2f1b 2f2f:[ 2f2f1b 2f2f2b 2f2f3b ] " |
1433 "2f3b ] 3b 4b "); | 1436 "2f3b ] 3b 4b "); |
1434 bookmarks::test::AddNodesFromModelString(model, root, model_string); | 1437 bookmarks::test::AddNodesFromModelString(model, root, model_string); |
1435 const BookmarkNode* other = model->other_node(); | 1438 const BookmarkNode* other = model->other_node(); |
1436 const std::string other_string("O1b O2b O3f:[ O3f1b O3f2f ] " | 1439 const std::string other_string("O1b O2b O3f:[ O3f1b O3f2f ] " |
1437 "O4f:[ O4f1b O4f2f ] 05b "); | 1440 "O4f:[ O4f1b O4f2f ] 05b "); |
1438 bookmarks::test::AddNodesFromModelString(model, other, other_string); | 1441 bookmarks::test::AddNodesFromModelString(model, other, other_string); |
1439 | 1442 |
1440 // Validate initial model. | 1443 // Validate initial model. |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1482 "2f2f1b 2f2f2b 2f2f3b O4f:[ O4f1b O4f2f ] ] " | 1485 "2f2f1b 2f2f2b 2f2f3b O4f:[ O4f1b O4f2f ] ] " |
1483 "2f3b ] 3b 4b "); | 1486 "2f3b ] 3b 4b "); |
1484 actual = bookmarks::test::ModelStringFromNode(root); | 1487 actual = bookmarks::test::ModelStringFromNode(root); |
1485 EXPECT_EQ(expectedA, actual); | 1488 EXPECT_EQ(expectedA, actual); |
1486 | 1489 |
1487 // Check button spacing. | 1490 // Check button spacing. |
1488 [folderController validateMenuSpacing]; | 1491 [folderController validateMenuSpacing]; |
1489 } | 1492 } |
1490 | 1493 |
1491 TEST_F(BookmarkBarFolderControllerMenuTest, DragBookmarkDataToTrash) { | 1494 TEST_F(BookmarkBarFolderControllerMenuTest, DragBookmarkDataToTrash) { |
1492 BookmarkModel* model = BookmarkModelFactory::GetForProfile(profile()); | 1495 BookmarkModel* model = BookmarkModelFactory::GetForBrowserContext(profile()); |
1493 const BookmarkNode* root = model->bookmark_bar_node(); | 1496 const BookmarkNode* root = model->bookmark_bar_node(); |
1494 const std::string model_string("1b 2f:[ 2f1b 2f2f:[ 2f2f1b 2f2f2b 2f2f3b ] " | 1497 const std::string model_string("1b 2f:[ 2f1b 2f2f:[ 2f2f1b 2f2f2b 2f2f3b ] " |
1495 "2f3b ] 3b 4b "); | 1498 "2f3b ] 3b 4b "); |
1496 bookmarks::test::AddNodesFromModelString(model, root, model_string); | 1499 bookmarks::test::AddNodesFromModelString(model, root, model_string); |
1497 | 1500 |
1498 // Validate initial model. | 1501 // Validate initial model. |
1499 std::string actual = bookmarks::test::ModelStringFromNode(root); | 1502 std::string actual = bookmarks::test::ModelStringFromNode(root); |
1500 EXPECT_EQ(model_string, actual); | 1503 EXPECT_EQ(model_string, actual); |
1501 | 1504 |
1502 const BookmarkNode* folderNode = root->GetChild(1); | 1505 const BookmarkNode* folderNode = root->GetChild(1); |
(...skipping 22 matching lines...) Expand all Loading... |
1525 const std::string expected("1b 2f:[ 2f2f:[ 2f2f1b 2f2f2b 2f2f3b ] " | 1528 const std::string expected("1b 2f:[ 2f2f:[ 2f2f1b 2f2f2b 2f2f3b ] " |
1526 "2f3b ] 3b 4b "); | 1529 "2f3b ] 3b 4b "); |
1527 actual = bookmarks::test::ModelStringFromNode(root); | 1530 actual = bookmarks::test::ModelStringFromNode(root); |
1528 EXPECT_EQ(expected, actual); | 1531 EXPECT_EQ(expected, actual); |
1529 | 1532 |
1530 // Check button spacing. | 1533 // Check button spacing. |
1531 [folderController validateMenuSpacing]; | 1534 [folderController validateMenuSpacing]; |
1532 } | 1535 } |
1533 | 1536 |
1534 TEST_F(BookmarkBarFolderControllerMenuTest, AddURLs) { | 1537 TEST_F(BookmarkBarFolderControllerMenuTest, AddURLs) { |
1535 BookmarkModel* model = BookmarkModelFactory::GetForProfile(profile()); | 1538 BookmarkModel* model = BookmarkModelFactory::GetForBrowserContext(profile()); |
1536 const BookmarkNode* root = model->bookmark_bar_node(); | 1539 const BookmarkNode* root = model->bookmark_bar_node(); |
1537 const std::string model_string("1b 2f:[ 2f1b 2f2f:[ 2f2f1b 2f2f2b 2f2f3b ] " | 1540 const std::string model_string("1b 2f:[ 2f1b 2f2f:[ 2f2f1b 2f2f2b 2f2f3b ] " |
1538 "2f3b ] 3b 4b "); | 1541 "2f3b ] 3b 4b "); |
1539 bookmarks::test::AddNodesFromModelString(model, root, model_string); | 1542 bookmarks::test::AddNodesFromModelString(model, root, model_string); |
1540 | 1543 |
1541 // Validate initial model. | 1544 // Validate initial model. |
1542 std::string actual = bookmarks::test::ModelStringFromNode(root); | 1545 std::string actual = bookmarks::test::ModelStringFromNode(root); |
1543 EXPECT_EQ(model_string, actual); | 1546 EXPECT_EQ(model_string, actual); |
1544 | 1547 |
1545 // Pop open a folder. | 1548 // Pop open a folder. |
(...skipping 24 matching lines...) Expand all Loading... |
1570 const std::string expected("1b 2f:[ SiteA SiteB 2f1b 2f2f:[ 2f2f1b 2f2f2b " | 1573 const std::string expected("1b 2f:[ SiteA SiteB 2f1b 2f2f:[ 2f2f1b 2f2f2b " |
1571 "2f2f3b ] 2f3b ] 3b 4b "); | 1574 "2f2f3b ] 2f3b ] 3b 4b "); |
1572 actual = bookmarks::test::ModelStringFromNode(root); | 1575 actual = bookmarks::test::ModelStringFromNode(root); |
1573 EXPECT_EQ(expected, actual); | 1576 EXPECT_EQ(expected, actual); |
1574 | 1577 |
1575 // Check button spacing. | 1578 // Check button spacing. |
1576 [folderController validateMenuSpacing]; | 1579 [folderController validateMenuSpacing]; |
1577 } | 1580 } |
1578 | 1581 |
1579 TEST_F(BookmarkBarFolderControllerMenuTest, DropPositionIndicator) { | 1582 TEST_F(BookmarkBarFolderControllerMenuTest, DropPositionIndicator) { |
1580 BookmarkModel* model = BookmarkModelFactory::GetForProfile(profile()); | 1583 BookmarkModel* model = BookmarkModelFactory::GetForBrowserContext(profile()); |
1581 const BookmarkNode* root = model->bookmark_bar_node(); | 1584 const BookmarkNode* root = model->bookmark_bar_node(); |
1582 const std::string model_string("1b 2f:[ 2f1b 2f2f:[ 2f2f1b 2f2f2b 2f2f3b ] " | 1585 const std::string model_string("1b 2f:[ 2f1b 2f2f:[ 2f2f1b 2f2f2b 2f2f3b ] " |
1583 "2f3b ] 3b 4b "); | 1586 "2f3b ] 3b 4b "); |
1584 bookmarks::test::AddNodesFromModelString(model, root, model_string); | 1587 bookmarks::test::AddNodesFromModelString(model, root, model_string); |
1585 | 1588 |
1586 // Validate initial model. | 1589 // Validate initial model. |
1587 std::string actual = bookmarks::test::ModelStringFromNode(root); | 1590 std::string actual = bookmarks::test::ModelStringFromNode(root); |
1588 EXPECT_EQ(model_string, actual); | 1591 EXPECT_EQ(model_string, actual); |
1589 | 1592 |
1590 // Pop open the folder. | 1593 // Pop open the folder. |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1630 | 1633 |
1631 bar_.reset([[BookmarkBarControllerNoDelete alloc] | 1634 bar_.reset([[BookmarkBarControllerNoDelete alloc] |
1632 initWithBrowser:browser() | 1635 initWithBrowser:browser() |
1633 initialWidth:NSWidth([parent_view_ frame]) | 1636 initialWidth:NSWidth([parent_view_ frame]) |
1634 delegate:nil]); | 1637 delegate:nil]); |
1635 InstallAndToggleBar(bar_.get()); | 1638 InstallAndToggleBar(bar_.get()); |
1636 } | 1639 } |
1637 }; | 1640 }; |
1638 | 1641 |
1639 TEST_F(BookmarkBarFolderControllerClosingTest, DeleteClosesFolder) { | 1642 TEST_F(BookmarkBarFolderControllerClosingTest, DeleteClosesFolder) { |
1640 BookmarkModel* model = BookmarkModelFactory::GetForProfile(profile()); | 1643 BookmarkModel* model = BookmarkModelFactory::GetForBrowserContext(profile()); |
1641 const BookmarkNode* root = model->bookmark_bar_node(); | 1644 const BookmarkNode* root = model->bookmark_bar_node(); |
1642 const std::string model_string("1b 2f:[ 2f1b 2f2f:[ 2f2f1b 2f2f2b ] " | 1645 const std::string model_string("1b 2f:[ 2f1b 2f2f:[ 2f2f1b 2f2f2b ] " |
1643 "2f3b ] 3b "); | 1646 "2f3b ] 3b "); |
1644 bookmarks::test::AddNodesFromModelString(model, root, model_string); | 1647 bookmarks::test::AddNodesFromModelString(model, root, model_string); |
1645 | 1648 |
1646 // Validate initial model. | 1649 // Validate initial model. |
1647 std::string actualModelString = bookmarks::test::ModelStringFromNode(root); | 1650 std::string actualModelString = bookmarks::test::ModelStringFromNode(root); |
1648 EXPECT_EQ(model_string, actualModelString); | 1651 EXPECT_EQ(model_string, actualModelString); |
1649 | 1652 |
1650 // Open the folder menu and submenu. | 1653 // Open the folder menu and submenu. |
(...skipping 15 matching lines...) Expand all Loading... |
1666 DeleteBookmark([folder parentButton], profile()); | 1669 DeleteBookmark([folder parentButton], profile()); |
1667 EXPECT_FALSE([folder folderController]); | 1670 EXPECT_FALSE([folder folderController]); |
1668 } | 1671 } |
1669 | 1672 |
1670 // TODO(jrg): draggingEntered: and draggingExited: trigger timers so | 1673 // TODO(jrg): draggingEntered: and draggingExited: trigger timers so |
1671 // they are hard to test. Factor out "fire timers" into routines | 1674 // they are hard to test. Factor out "fire timers" into routines |
1672 // which can be overridden to fire immediately to make behavior | 1675 // which can be overridden to fire immediately to make behavior |
1673 // confirmable. | 1676 // confirmable. |
1674 // There is a similar problem with mouseEnteredButton: and | 1677 // There is a similar problem with mouseEnteredButton: and |
1675 // mouseExitedButton:. | 1678 // mouseExitedButton:. |
OLD | NEW |