| 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 #import <Cocoa/Cocoa.h> | 5 #import <Cocoa/Cocoa.h> |
| 6 | 6 |
| 7 #include "base/basictypes.h" | 7 #include "base/basictypes.h" |
| 8 #include "base/command_line.h" | 8 #include "base/command_line.h" |
| 9 #include "base/mac/scoped_nsobject.h" | 9 #include "base/mac/scoped_nsobject.h" |
| 10 #include "base/strings/string16.h" | 10 #include "base/strings/string16.h" |
| (...skipping 541 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 552 } | 552 } |
| 553 | 553 |
| 554 // Confirm off the side button only enabled when reasonable. | 554 // Confirm off the side button only enabled when reasonable. |
| 555 TEST_F(BookmarkBarControllerTest, OffTheSideButtonHidden) { | 555 TEST_F(BookmarkBarControllerTest, OffTheSideButtonHidden) { |
| 556 BookmarkModel* model = BookmarkModelFactory::GetForProfile(profile()); | 556 BookmarkModel* model = BookmarkModelFactory::GetForProfile(profile()); |
| 557 | 557 |
| 558 [bar_ loaded:model]; | 558 [bar_ loaded:model]; |
| 559 EXPECT_TRUE([bar_ offTheSideButtonIsHidden]); | 559 EXPECT_TRUE([bar_ offTheSideButtonIsHidden]); |
| 560 | 560 |
| 561 for (int i = 0; i < 2; i++) { | 561 for (int i = 0; i < 2; i++) { |
| 562 bookmark_utils::AddIfNotBookmarked( | 562 bookmarks::AddIfNotBookmarked( |
| 563 model, GURL("http://www.foo.com"), ASCIIToUTF16("small")); | 563 model, GURL("http://www.foo.com"), ASCIIToUTF16("small")); |
| 564 EXPECT_TRUE([bar_ offTheSideButtonIsHidden]); | 564 EXPECT_TRUE([bar_ offTheSideButtonIsHidden]); |
| 565 } | 565 } |
| 566 | 566 |
| 567 const BookmarkNode* parent = model->bookmark_bar_node(); | 567 const BookmarkNode* parent = model->bookmark_bar_node(); |
| 568 for (int i = 0; i < 20; i++) { | 568 for (int i = 0; i < 20; i++) { |
| 569 model->AddURL(parent, parent->child_count(), | 569 model->AddURL(parent, parent->child_count(), |
| 570 ASCIIToUTF16("super duper wide title"), | 570 ASCIIToUTF16("super duper wide title"), |
| 571 GURL("http://superfriends.hall-of-justice.edu")); | 571 GURL("http://superfriends.hall-of-justice.edu")); |
| 572 } | 572 } |
| (...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 685 | 685 |
| 686 TEST_F(BookmarkBarControllerTest, MenuForFolderNode) { | 686 TEST_F(BookmarkBarControllerTest, MenuForFolderNode) { |
| 687 BookmarkModel* model = BookmarkModelFactory::GetForProfile(profile()); | 687 BookmarkModel* model = BookmarkModelFactory::GetForProfile(profile()); |
| 688 | 688 |
| 689 // First make sure something (e.g. "(empty)" string) is always present. | 689 // First make sure something (e.g. "(empty)" string) is always present. |
| 690 NSMenu* menu = [bar_ menuForFolderNode:model->bookmark_bar_node()]; | 690 NSMenu* menu = [bar_ menuForFolderNode:model->bookmark_bar_node()]; |
| 691 EXPECT_GT([menu numberOfItems], 0); | 691 EXPECT_GT([menu numberOfItems], 0); |
| 692 | 692 |
| 693 // Test two bookmarks. | 693 // Test two bookmarks. |
| 694 GURL gurl("http://www.foo.com"); | 694 GURL gurl("http://www.foo.com"); |
| 695 bookmark_utils::AddIfNotBookmarked(model, gurl, ASCIIToUTF16("small")); | 695 bookmarks::AddIfNotBookmarked(model, gurl, ASCIIToUTF16("small")); |
| 696 bookmark_utils::AddIfNotBookmarked( | 696 bookmarks::AddIfNotBookmarked( |
| 697 model, GURL("http://www.cnn.com"), ASCIIToUTF16("bigger title")); | 697 model, GURL("http://www.cnn.com"), ASCIIToUTF16("bigger title")); |
| 698 menu = [bar_ menuForFolderNode:model->bookmark_bar_node()]; | 698 menu = [bar_ menuForFolderNode:model->bookmark_bar_node()]; |
| 699 EXPECT_EQ([menu numberOfItems], 2); | 699 EXPECT_EQ([menu numberOfItems], 2); |
| 700 NSMenuItem *item = [menu itemWithTitle:@"bigger title"]; | 700 NSMenuItem *item = [menu itemWithTitle:@"bigger title"]; |
| 701 EXPECT_TRUE(item); | 701 EXPECT_TRUE(item); |
| 702 item = [menu itemWithTitle:@"small"]; | 702 item = [menu itemWithTitle:@"small"]; |
| 703 EXPECT_TRUE(item); | 703 EXPECT_TRUE(item); |
| 704 if (item) { | 704 if (item) { |
| 705 int64 tag = [bar_ nodeIdFromMenuTag:[item tag]]; | 705 int64 tag = [bar_ nodeIdFromMenuTag:[item tag]]; |
| 706 const BookmarkNode* node = GetBookmarkNodeByID(model, tag); | 706 const BookmarkNode* node = bookmarks::GetBookmarkNodeByID(model, tag); |
| 707 EXPECT_TRUE(node); | 707 EXPECT_TRUE(node); |
| 708 EXPECT_EQ(gurl, node->url()); | 708 EXPECT_EQ(gurl, node->url()); |
| 709 } | 709 } |
| 710 | 710 |
| 711 // Test with an actual folder as well | 711 // Test with an actual folder as well |
| 712 const BookmarkNode* parent = model->bookmark_bar_node(); | 712 const BookmarkNode* parent = model->bookmark_bar_node(); |
| 713 const BookmarkNode* folder = model->AddFolder(parent, | 713 const BookmarkNode* folder = model->AddFolder(parent, |
| 714 parent->child_count(), | 714 parent->child_count(), |
| 715 ASCIIToUTF16("folder")); | 715 ASCIIToUTF16("folder")); |
| 716 model->AddURL(folder, folder->child_count(), | 716 model->AddURL(folder, folder->child_count(), |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 757 [bar_ clearBookmarkBar]; | 757 [bar_ clearBookmarkBar]; |
| 758 EXPECT_EQ(0U, [[bar_ buttons] count]); | 758 EXPECT_EQ(0U, [[bar_ buttons] count]); |
| 759 EXPECT_EQ(initial_subview_count, [[buttonView subviews] count]); | 759 EXPECT_EQ(initial_subview_count, [[buttonView subviews] count]); |
| 760 | 760 |
| 761 GURL gurl1("http://superfriends.hall-of-justice.edu"); | 761 GURL gurl1("http://superfriends.hall-of-justice.edu"); |
| 762 // Short titles increase the chances of this test succeeding if the view is | 762 // Short titles increase the chances of this test succeeding if the view is |
| 763 // narrow. | 763 // narrow. |
| 764 // TODO(viettrungluu): make the test independent of window/view size, font | 764 // TODO(viettrungluu): make the test independent of window/view size, font |
| 765 // metrics, button size and spacing, and everything else. | 765 // metrics, button size and spacing, and everything else. |
| 766 base::string16 title1(ASCIIToUTF16("x")); | 766 base::string16 title1(ASCIIToUTF16("x")); |
| 767 bookmark_utils::AddIfNotBookmarked(model, gurl1, title1); | 767 bookmarks::AddIfNotBookmarked(model, gurl1, title1); |
| 768 EXPECT_EQ(1U, [[bar_ buttons] count]); | 768 EXPECT_EQ(1U, [[bar_ buttons] count]); |
| 769 EXPECT_EQ(1+initial_subview_count, [[buttonView subviews] count]); | 769 EXPECT_EQ(1+initial_subview_count, [[buttonView subviews] count]); |
| 770 | 770 |
| 771 GURL gurl2("http://legion-of-doom.gov"); | 771 GURL gurl2("http://legion-of-doom.gov"); |
| 772 base::string16 title2(ASCIIToUTF16("y")); | 772 base::string16 title2(ASCIIToUTF16("y")); |
| 773 bookmark_utils::AddIfNotBookmarked(model, gurl2, title2); | 773 bookmarks::AddIfNotBookmarked(model, gurl2, title2); |
| 774 EXPECT_EQ(2U, [[bar_ buttons] count]); | 774 EXPECT_EQ(2U, [[bar_ buttons] count]); |
| 775 EXPECT_EQ(2+initial_subview_count, [[buttonView subviews] count]); | 775 EXPECT_EQ(2+initial_subview_count, [[buttonView subviews] count]); |
| 776 | 776 |
| 777 for (int i = 0; i < 3; i++) { | 777 for (int i = 0; i < 3; i++) { |
| 778 bookmark_utils::RemoveAllBookmarks(model, gurl2); | 778 bookmarks::RemoveAllBookmarks(model, gurl2); |
| 779 EXPECT_EQ(1U, [[bar_ buttons] count]); | 779 EXPECT_EQ(1U, [[bar_ buttons] count]); |
| 780 EXPECT_EQ(1+initial_subview_count, [[buttonView subviews] count]); | 780 EXPECT_EQ(1+initial_subview_count, [[buttonView subviews] count]); |
| 781 | 781 |
| 782 // and bring it back | 782 // and bring it back |
| 783 bookmark_utils::AddIfNotBookmarked(model, gurl2, title2); | 783 bookmarks::AddIfNotBookmarked(model, gurl2, title2); |
| 784 EXPECT_EQ(2U, [[bar_ buttons] count]); | 784 EXPECT_EQ(2U, [[bar_ buttons] count]); |
| 785 EXPECT_EQ(2+initial_subview_count, [[buttonView subviews] count]); | 785 EXPECT_EQ(2+initial_subview_count, [[buttonView subviews] count]); |
| 786 } | 786 } |
| 787 | 787 |
| 788 [bar_ clearBookmarkBar]; | 788 [bar_ clearBookmarkBar]; |
| 789 EXPECT_EQ(0U, [[bar_ buttons] count]); | 789 EXPECT_EQ(0U, [[bar_ buttons] count]); |
| 790 EXPECT_EQ(initial_subview_count, [[buttonView subviews] count]); | 790 EXPECT_EQ(initial_subview_count, [[buttonView subviews] count]); |
| 791 | 791 |
| 792 // Explicit test of loaded: since this is a convenient spot | 792 // Explicit test of loaded: since this is a convenient spot |
| 793 [bar_ loaded:model]; | 793 [bar_ loaded:model]; |
| (...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 854 EXPECT_GE(r.origin.x, x_end); | 854 EXPECT_GE(r.origin.x, x_end); |
| 855 x_end = NSMaxX(r); | 855 x_end = NSMaxX(r); |
| 856 } | 856 } |
| 857 } | 857 } |
| 858 | 858 |
| 859 TEST_F(BookmarkBarControllerTest, CheckForGrowth) { | 859 TEST_F(BookmarkBarControllerTest, CheckForGrowth) { |
| 860 WithNoAnimation at_all; // Turn off Cocoa auto animation in this scope. | 860 WithNoAnimation at_all; // Turn off Cocoa auto animation in this scope. |
| 861 BookmarkModel* model = BookmarkModelFactory::GetForProfile(profile()); | 861 BookmarkModel* model = BookmarkModelFactory::GetForProfile(profile()); |
| 862 GURL gurl1("http://www.google.com"); | 862 GURL gurl1("http://www.google.com"); |
| 863 base::string16 title1(ASCIIToUTF16("x")); | 863 base::string16 title1(ASCIIToUTF16("x")); |
| 864 bookmark_utils::AddIfNotBookmarked(model, gurl1, title1); | 864 bookmarks::AddIfNotBookmarked(model, gurl1, title1); |
| 865 | 865 |
| 866 GURL gurl2("http://www.google.com/blah"); | 866 GURL gurl2("http://www.google.com/blah"); |
| 867 base::string16 title2(ASCIIToUTF16("y")); | 867 base::string16 title2(ASCIIToUTF16("y")); |
| 868 bookmark_utils::AddIfNotBookmarked(model, gurl2, title2); | 868 bookmarks::AddIfNotBookmarked(model, gurl2, title2); |
| 869 | 869 |
| 870 EXPECT_EQ(2U, [[bar_ buttons] count]); | 870 EXPECT_EQ(2U, [[bar_ buttons] count]); |
| 871 CGFloat width_1 = [[[bar_ buttons] objectAtIndex:0] frame].size.width; | 871 CGFloat width_1 = [[[bar_ buttons] objectAtIndex:0] frame].size.width; |
| 872 CGFloat x_2 = [[[bar_ buttons] objectAtIndex:1] frame].origin.x; | 872 CGFloat x_2 = [[[bar_ buttons] objectAtIndex:1] frame].origin.x; |
| 873 | 873 |
| 874 NSButton* first = [[bar_ buttons] objectAtIndex:0]; | 874 NSButton* first = [[bar_ buttons] objectAtIndex:0]; |
| 875 [[first cell] setTitle:@"This is a really big title; watch out mom!"]; | 875 [[first cell] setTitle:@"This is a really big title; watch out mom!"]; |
| 876 [bar_ checkForBookmarkButtonGrowth:first]; | 876 [bar_ checkForBookmarkButtonGrowth:first]; |
| 877 | 877 |
| 878 // Make sure the 1st button is now wider, the 2nd one is moved over, | 878 // Make sure the 1st button is now wider, the 2nd one is moved over, |
| (...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 937 // Test drawing, mostly to ensure nothing leaks or crashes. | 937 // Test drawing, mostly to ensure nothing leaks or crashes. |
| 938 TEST_F(BookmarkBarControllerTest, Display) { | 938 TEST_F(BookmarkBarControllerTest, Display) { |
| 939 [[bar_ view] display]; | 939 [[bar_ view] display]; |
| 940 } | 940 } |
| 941 | 941 |
| 942 // Test that middle clicking on a bookmark button results in an open action. | 942 // Test that middle clicking on a bookmark button results in an open action. |
| 943 TEST_F(BookmarkBarControllerTest, MiddleClick) { | 943 TEST_F(BookmarkBarControllerTest, MiddleClick) { |
| 944 BookmarkModel* model = BookmarkModelFactory::GetForProfile(profile()); | 944 BookmarkModel* model = BookmarkModelFactory::GetForProfile(profile()); |
| 945 GURL gurl1("http://www.google.com/"); | 945 GURL gurl1("http://www.google.com/"); |
| 946 base::string16 title1(ASCIIToUTF16("x")); | 946 base::string16 title1(ASCIIToUTF16("x")); |
| 947 bookmark_utils::AddIfNotBookmarked(model, gurl1, title1); | 947 bookmarks::AddIfNotBookmarked(model, gurl1, title1); |
| 948 | 948 |
| 949 EXPECT_EQ(1U, [[bar_ buttons] count]); | 949 EXPECT_EQ(1U, [[bar_ buttons] count]); |
| 950 NSButton* first = [[bar_ buttons] objectAtIndex:0]; | 950 NSButton* first = [[bar_ buttons] objectAtIndex:0]; |
| 951 EXPECT_TRUE(first); | 951 EXPECT_TRUE(first); |
| 952 | 952 |
| 953 [first otherMouseUp: | 953 [first otherMouseUp: |
| 954 cocoa_test_event_utils::MouseEventWithType(NSOtherMouseUp, 0)]; | 954 cocoa_test_event_utils::MouseEventWithType(NSOtherMouseUp, 0)]; |
| 955 EXPECT_EQ(noOpenBar()->urls_.size(), 1U); | 955 EXPECT_EQ(noOpenBar()->urls_.size(), 1U); |
| 956 } | 956 } |
| 957 | 957 |
| (...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1037 WithNoAnimation at_all; | 1037 WithNoAnimation at_all; |
| 1038 BookmarkModel* model = BookmarkModelFactory::GetForProfile(profile()); | 1038 BookmarkModel* model = BookmarkModelFactory::GetForProfile(profile()); |
| 1039 | 1039 |
| 1040 GURL gurls[] = { GURL("http://www.google.com/a"), | 1040 GURL gurls[] = { GURL("http://www.google.com/a"), |
| 1041 GURL("http://www.google.com/b"), | 1041 GURL("http://www.google.com/b"), |
| 1042 GURL("http://www.google.com/c") }; | 1042 GURL("http://www.google.com/c") }; |
| 1043 base::string16 titles[] = { ASCIIToUTF16("a"), | 1043 base::string16 titles[] = { ASCIIToUTF16("a"), |
| 1044 ASCIIToUTF16("b"), | 1044 ASCIIToUTF16("b"), |
| 1045 ASCIIToUTF16("c") }; | 1045 ASCIIToUTF16("c") }; |
| 1046 for (unsigned i = 0; i < arraysize(titles); i++) | 1046 for (unsigned i = 0; i < arraysize(titles); i++) |
| 1047 bookmark_utils::AddIfNotBookmarked(model, gurls[i], titles[i]); | 1047 bookmarks::AddIfNotBookmarked(model, gurls[i], titles[i]); |
| 1048 | 1048 |
| 1049 EXPECT_EQ([[bar_ buttons] count], arraysize(titles)); | 1049 EXPECT_EQ([[bar_ buttons] count], arraysize(titles)); |
| 1050 EXPECT_NSEQ(@"a", [[[bar_ buttons] objectAtIndex:0] title]); | 1050 EXPECT_NSEQ(@"a", [[[bar_ buttons] objectAtIndex:0] title]); |
| 1051 | 1051 |
| 1052 [bar_ dragButton:[[bar_ buttons] objectAtIndex:2] | 1052 [bar_ dragButton:[[bar_ buttons] objectAtIndex:2] |
| 1053 to:NSZeroPoint | 1053 to:NSZeroPoint |
| 1054 copy:NO]; | 1054 copy:NO]; |
| 1055 EXPECT_NSEQ(@"c", [[[bar_ buttons] objectAtIndex:0] title]); | 1055 EXPECT_NSEQ(@"c", [[[bar_ buttons] objectAtIndex:0] title]); |
| 1056 // Make sure a 'copy' did not happen. | 1056 // Make sure a 'copy' did not happen. |
| 1057 EXPECT_EQ([[bar_ buttons] count], arraysize(titles)); | 1057 EXPECT_EQ([[bar_ buttons] count], arraysize(titles)); |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1109 TEST_F(BookmarkBarControllerTest, TestCopyButton) { | 1109 TEST_F(BookmarkBarControllerTest, TestCopyButton) { |
| 1110 BookmarkModel* model = BookmarkModelFactory::GetForProfile(profile()); | 1110 BookmarkModel* model = BookmarkModelFactory::GetForProfile(profile()); |
| 1111 | 1111 |
| 1112 GURL gurls[] = { GURL("http://www.google.com/a"), | 1112 GURL gurls[] = { GURL("http://www.google.com/a"), |
| 1113 GURL("http://www.google.com/b"), | 1113 GURL("http://www.google.com/b"), |
| 1114 GURL("http://www.google.com/c") }; | 1114 GURL("http://www.google.com/c") }; |
| 1115 base::string16 titles[] = { ASCIIToUTF16("a"), | 1115 base::string16 titles[] = { ASCIIToUTF16("a"), |
| 1116 ASCIIToUTF16("b"), | 1116 ASCIIToUTF16("b"), |
| 1117 ASCIIToUTF16("c") }; | 1117 ASCIIToUTF16("c") }; |
| 1118 for (unsigned i = 0; i < arraysize(titles); i++) | 1118 for (unsigned i = 0; i < arraysize(titles); i++) |
| 1119 bookmark_utils::AddIfNotBookmarked(model, gurls[i], titles[i]); | 1119 bookmarks::AddIfNotBookmarked(model, gurls[i], titles[i]); |
| 1120 | 1120 |
| 1121 EXPECT_EQ([[bar_ buttons] count], arraysize(titles)); | 1121 EXPECT_EQ([[bar_ buttons] count], arraysize(titles)); |
| 1122 EXPECT_NSEQ(@"a", [[[bar_ buttons] objectAtIndex:0] title]); | 1122 EXPECT_NSEQ(@"a", [[[bar_ buttons] objectAtIndex:0] title]); |
| 1123 | 1123 |
| 1124 // Drag 'a' between 'b' and 'c'. | 1124 // Drag 'a' between 'b' and 'c'. |
| 1125 CGFloat x = NSMinX([[[bar_ buttons] objectAtIndex:2] frame]); | 1125 CGFloat x = NSMinX([[[bar_ buttons] objectAtIndex:2] frame]); |
| 1126 x += [[bar_ view] frame].origin.x; | 1126 x += [[bar_ view] frame].origin.x; |
| 1127 [bar_ dragButton:[[bar_ buttons] objectAtIndex:0] | 1127 [bar_ dragButton:[[bar_ buttons] objectAtIndex:0] |
| 1128 to:NSMakePoint(x, 0) | 1128 to:NSMakePoint(x, 0) |
| 1129 copy:YES]; | 1129 copy:YES]; |
| 1130 EXPECT_NSEQ(@"a", [[[bar_ buttons] objectAtIndex:0] title]); | 1130 EXPECT_NSEQ(@"a", [[[bar_ buttons] objectAtIndex:0] title]); |
| 1131 EXPECT_NSEQ(@"b", [[[bar_ buttons] objectAtIndex:1] title]); | 1131 EXPECT_NSEQ(@"b", [[[bar_ buttons] objectAtIndex:1] title]); |
| 1132 EXPECT_NSEQ(@"a", [[[bar_ buttons] objectAtIndex:2] title]); | 1132 EXPECT_NSEQ(@"a", [[[bar_ buttons] objectAtIndex:2] title]); |
| 1133 EXPECT_NSEQ(@"c", [[[bar_ buttons] objectAtIndex:3] title]); | 1133 EXPECT_NSEQ(@"c", [[[bar_ buttons] objectAtIndex:3] title]); |
| 1134 EXPECT_EQ([[bar_ buttons] count], 4U); | 1134 EXPECT_EQ([[bar_ buttons] count], 4U); |
| 1135 } | 1135 } |
| 1136 | 1136 |
| 1137 // Fake a theme with colored text. Apply it and make sure bookmark | 1137 // Fake a theme with colored text. Apply it and make sure bookmark |
| 1138 // buttons have the same colored text. Repeat more than once. | 1138 // buttons have the same colored text. Repeat more than once. |
| 1139 TEST_F(BookmarkBarControllerTest, TestThemedButton) { | 1139 TEST_F(BookmarkBarControllerTest, TestThemedButton) { |
| 1140 BookmarkModel* model = BookmarkModelFactory::GetForProfile(profile()); | 1140 BookmarkModel* model = BookmarkModelFactory::GetForProfile(profile()); |
| 1141 bookmark_utils::AddIfNotBookmarked( | 1141 bookmarks::AddIfNotBookmarked( |
| 1142 model, GURL("http://www.foo.com"), ASCIIToUTF16("small")); | 1142 model, GURL("http://www.foo.com"), ASCIIToUTF16("small")); |
| 1143 BookmarkButton* button = [[bar_ buttons] objectAtIndex:0]; | 1143 BookmarkButton* button = [[bar_ buttons] objectAtIndex:0]; |
| 1144 EXPECT_TRUE(button); | 1144 EXPECT_TRUE(button); |
| 1145 | 1145 |
| 1146 NSArray* colors = [NSArray arrayWithObjects:[NSColor redColor], | 1146 NSArray* colors = [NSArray arrayWithObjects:[NSColor redColor], |
| 1147 [NSColor blueColor], | 1147 [NSColor blueColor], |
| 1148 nil]; | 1148 nil]; |
| 1149 for (NSColor* color in colors) { | 1149 for (NSColor* color in colors) { |
| 1150 FakeTheme theme(color); | 1150 FakeTheme theme(color); |
| 1151 [bar_ updateTheme:&theme]; | 1151 [bar_ updateTheme:&theme]; |
| (...skipping 12 matching lines...) Expand all Loading... |
| 1164 TEST_F(BookmarkBarControllerTest, TestClearOnDealloc) { | 1164 TEST_F(BookmarkBarControllerTest, TestClearOnDealloc) { |
| 1165 // Make some bookmark buttons. | 1165 // Make some bookmark buttons. |
| 1166 BookmarkModel* model = BookmarkModelFactory::GetForProfile(profile()); | 1166 BookmarkModel* model = BookmarkModelFactory::GetForProfile(profile()); |
| 1167 GURL gurls[] = { GURL("http://www.foo.com/"), | 1167 GURL gurls[] = { GURL("http://www.foo.com/"), |
| 1168 GURL("http://www.bar.com/"), | 1168 GURL("http://www.bar.com/"), |
| 1169 GURL("http://www.baz.com/") }; | 1169 GURL("http://www.baz.com/") }; |
| 1170 base::string16 titles[] = { ASCIIToUTF16("a"), | 1170 base::string16 titles[] = { ASCIIToUTF16("a"), |
| 1171 ASCIIToUTF16("b"), | 1171 ASCIIToUTF16("b"), |
| 1172 ASCIIToUTF16("c") }; | 1172 ASCIIToUTF16("c") }; |
| 1173 for (size_t i = 0; i < arraysize(titles); i++) | 1173 for (size_t i = 0; i < arraysize(titles); i++) |
| 1174 bookmark_utils::AddIfNotBookmarked(model, gurls[i], titles[i]); | 1174 bookmarks::AddIfNotBookmarked(model, gurls[i], titles[i]); |
| 1175 | 1175 |
| 1176 // Get and retain the buttons so we can examine them after dealloc. | 1176 // Get and retain the buttons so we can examine them after dealloc. |
| 1177 base::scoped_nsobject<NSArray> buttons([[bar_ buttons] retain]); | 1177 base::scoped_nsobject<NSArray> buttons([[bar_ buttons] retain]); |
| 1178 EXPECT_EQ([buttons count], arraysize(titles)); | 1178 EXPECT_EQ([buttons count], arraysize(titles)); |
| 1179 | 1179 |
| 1180 // Make sure that everything is set. | 1180 // Make sure that everything is set. |
| 1181 for (BookmarkButton* button in buttons.get()) { | 1181 for (BookmarkButton* button in buttons.get()) { |
| 1182 ASSERT_TRUE([button isKindOfClass:[BookmarkButton class]]); | 1182 ASSERT_TRUE([button isKindOfClass:[BookmarkButton class]]); |
| 1183 EXPECT_TRUE([button delegate]); | 1183 EXPECT_TRUE([button delegate]); |
| 1184 EXPECT_TRUE([button target]); | 1184 EXPECT_TRUE([button target]); |
| (...skipping 912 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2097 "2f3b ] 4b "); | 2097 "2f3b ] 4b "); |
| 2098 actual = test::ModelStringFromNode(root); | 2098 actual = test::ModelStringFromNode(root); |
| 2099 EXPECT_EQ(expected, actual); | 2099 EXPECT_EQ(expected, actual); |
| 2100 | 2100 |
| 2101 // Verify that the other bookmark folder can't be deleted. | 2101 // Verify that the other bookmark folder can't be deleted. |
| 2102 BookmarkButton *otherButton = [bar_ otherBookmarksButton]; | 2102 BookmarkButton *otherButton = [bar_ otherBookmarksButton]; |
| 2103 EXPECT_FALSE([bar_ canDragBookmarkButtonToTrash:otherButton]); | 2103 EXPECT_FALSE([bar_ canDragBookmarkButtonToTrash:otherButton]); |
| 2104 } | 2104 } |
| 2105 | 2105 |
| 2106 } // namespace | 2106 } // namespace |
| OLD | NEW |