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 921 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
932 EXPECT_TRUE([cell title]); | 932 EXPECT_TRUE([cell title]); |
933 | 933 |
934 // cell is autoreleased; no need to release here | 934 // cell is autoreleased; no need to release here |
935 } | 935 } |
936 | 936 |
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 // except for offTheSideButton, as it just opens its folder menu. |
943 TEST_F(BookmarkBarControllerTest, MiddleClick) { | 944 TEST_F(BookmarkBarControllerTest, MiddleClick) { |
944 BookmarkModel* model = BookmarkModelFactory::GetForProfile(profile()); | 945 BookmarkModel* model = BookmarkModelFactory::GetForProfile(profile()); |
945 GURL gurl1("http://www.google.com/"); | 946 GURL gurl1("http://www.google.com/"); |
946 base::string16 title1(ASCIIToUTF16("x")); | 947 base::string16 title1(ASCIIToUTF16("x")); |
947 bookmarks::AddIfNotBookmarked(model, gurl1, title1); | 948 bookmarks::AddIfNotBookmarked(model, gurl1, title1); |
948 | 949 |
949 EXPECT_EQ(1U, [[bar_ buttons] count]); | 950 EXPECT_EQ(1U, [[bar_ buttons] count]); |
950 NSButton* first = [[bar_ buttons] objectAtIndex:0]; | 951 NSButton* first = [[bar_ buttons] objectAtIndex:0]; |
951 EXPECT_TRUE(first); | 952 EXPECT_TRUE(first); |
952 | 953 |
953 [first otherMouseUp: | 954 [first otherMouseUp: |
954 cocoa_test_event_utils::MouseEventWithType(NSOtherMouseUp, 0)]; | 955 cocoa_test_event_utils::MouseEventWithType(NSOtherMouseUp, 0)]; |
955 EXPECT_EQ(noOpenBar()->urls_.size(), 1U); | 956 EXPECT_EQ(noOpenBar()->urls_.size(), 1U); |
| 957 |
| 958 // Test for offTheSideButton. |
| 959 // Add more bookmarks so that offTheSideButton is visible. |
| 960 const BookmarkNode* parent = model->bookmark_bar_node(); |
| 961 for (int i = 0; i < 20; i++) { |
| 962 model->AddURL(parent, parent->child_count(), |
| 963 ASCIIToUTF16("super duper wide title"), |
| 964 GURL("http://superfriends.hall-of-justice.edu")); |
| 965 } |
| 966 EXPECT_FALSE([bar_ offTheSideButtonIsHidden]); |
| 967 |
| 968 NSButton* offTheSideButton = [bar_ offTheSideButton]; |
| 969 EXPECT_TRUE(offTheSideButton); |
| 970 [offTheSideButton otherMouseUp: |
| 971 cocoa_test_event_utils::MouseEventWithType(NSOtherMouseUp, 0)]; |
| 972 |
| 973 // Middle click on offTheSideButton should not open any bookmarks under it, |
| 974 // therefore urls size should still be 1. |
| 975 EXPECT_EQ(noOpenBar()->urls_.size(), 1U); |
| 976 |
| 977 // Check that folderController should not be NULL since offTheSideButton |
| 978 // folder is currently open. |
| 979 BookmarkBarFolderController* bbfc = [bar_ folderController]; |
| 980 EXPECT_TRUE(bbfc); |
| 981 EXPECT_TRUE([bbfc parentButton] == offTheSideButton); |
| 982 |
| 983 // Middle clicking again on it should close the folder. |
| 984 [offTheSideButton otherMouseUp: |
| 985 cocoa_test_event_utils::MouseEventWithType(NSOtherMouseUp, 0)]; |
| 986 bbfc = [bar_ folderController]; |
| 987 EXPECT_FALSE(bbfc); |
956 } | 988 } |
957 | 989 |
958 TEST_F(BookmarkBarControllerTest, DisplaysHelpMessageOnEmpty) { | 990 TEST_F(BookmarkBarControllerTest, DisplaysHelpMessageOnEmpty) { |
959 BookmarkModel* model = BookmarkModelFactory::GetForProfile(profile()); | 991 BookmarkModel* model = BookmarkModelFactory::GetForProfile(profile()); |
960 [bar_ loaded:model]; | 992 [bar_ loaded:model]; |
961 EXPECT_FALSE([[[bar_ buttonView] noItemContainer] isHidden]); | 993 EXPECT_FALSE([[[bar_ buttonView] noItemContainer] isHidden]); |
962 } | 994 } |
963 | 995 |
964 TEST_F(BookmarkBarControllerTest, HidesHelpMessageWithBookmark) { | 996 TEST_F(BookmarkBarControllerTest, HidesHelpMessageWithBookmark) { |
965 BookmarkModel* model = BookmarkModelFactory::GetForProfile(profile()); | 997 BookmarkModel* model = BookmarkModelFactory::GetForProfile(profile()); |
(...skipping 1131 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2097 "2f3b ] 4b "); | 2129 "2f3b ] 4b "); |
2098 actual = test::ModelStringFromNode(root); | 2130 actual = test::ModelStringFromNode(root); |
2099 EXPECT_EQ(expected, actual); | 2131 EXPECT_EQ(expected, actual); |
2100 | 2132 |
2101 // Verify that the other bookmark folder can't be deleted. | 2133 // Verify that the other bookmark folder can't be deleted. |
2102 BookmarkButton *otherButton = [bar_ otherBookmarksButton]; | 2134 BookmarkButton *otherButton = [bar_ otherBookmarksButton]; |
2103 EXPECT_FALSE([bar_ canDragBookmarkButtonToTrash:otherButton]); | 2135 EXPECT_FALSE([bar_ canDragBookmarkButtonToTrash:otherButton]); |
2104 } | 2136 } |
2105 | 2137 |
2106 } // namespace | 2138 } // namespace |
OLD | NEW |