| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/memory/scoped_nsobject.h" | 9 #include "base/memory/scoped_nsobject.h" |
| 10 #include "base/string16.h" | 10 #include "base/string16.h" |
| (...skipping 968 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 979 BookmarkModel* model = profile()->GetBookmarkModel(); | 979 BookmarkModel* model = profile()->GetBookmarkModel(); |
| 980 GURL gurl1("http://www.google.com/"); | 980 GURL gurl1("http://www.google.com/"); |
| 981 string16 title1(ASCIIToUTF16("x")); | 981 string16 title1(ASCIIToUTF16("x")); |
| 982 bookmark_utils::AddIfNotBookmarked(model, gurl1, title1); | 982 bookmark_utils::AddIfNotBookmarked(model, gurl1, title1); |
| 983 | 983 |
| 984 EXPECT_EQ(1U, [[bar_ buttons] count]); | 984 EXPECT_EQ(1U, [[bar_ buttons] count]); |
| 985 NSButton* first = [[bar_ buttons] objectAtIndex:0]; | 985 NSButton* first = [[bar_ buttons] objectAtIndex:0]; |
| 986 EXPECT_TRUE(first); | 986 EXPECT_TRUE(first); |
| 987 | 987 |
| 988 [first otherMouseUp: | 988 [first otherMouseUp: |
| 989 cocoa_test_event_utils::MakeMouseEvent(NSOtherMouseUp, 0)]; | 989 cocoa_test_event_utils::MouseEventWithType(NSOtherMouseUp, 0)]; |
| 990 EXPECT_EQ(noOpenBar()->urls_.size(), 1U); | 990 EXPECT_EQ(noOpenBar()->urls_.size(), 1U); |
| 991 } | 991 } |
| 992 | 992 |
| 993 TEST_F(BookmarkBarControllerTest, DisplaysHelpMessageOnEmpty) { | 993 TEST_F(BookmarkBarControllerTest, DisplaysHelpMessageOnEmpty) { |
| 994 BookmarkModel* model = profile()->GetBookmarkModel(); | 994 BookmarkModel* model = profile()->GetBookmarkModel(); |
| 995 [bar_ loaded:model]; | 995 [bar_ loaded:model]; |
| 996 EXPECT_FALSE([[[bar_ buttonView] noItemContainer] isHidden]); | 996 EXPECT_FALSE([[[bar_ buttonView] noItemContainer] isHidden]); |
| 997 } | 997 } |
| 998 | 998 |
| 999 TEST_F(BookmarkBarControllerTest, HidesHelpMessageWithBookmark) { | 999 TEST_F(BookmarkBarControllerTest, HidesHelpMessageWithBookmark) { |
| (...skipping 296 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1296 parent->child_count(), | 1296 parent->child_count(), |
| 1297 ASCIIToUTF16("folder")); | 1297 ASCIIToUTF16("folder")); |
| 1298 model->AddURL(folder, folder->child_count(), | 1298 model->AddURL(folder, folder->child_count(), |
| 1299 ASCIIToUTF16("f1"), GURL("http://framma-lamma.com")); | 1299 ASCIIToUTF16("f1"), GURL("http://framma-lamma.com")); |
| 1300 folder = model->AddFolder(parent, parent->child_count(), | 1300 folder = model->AddFolder(parent, parent->child_count(), |
| 1301 ASCIIToUTF16("empty")); | 1301 ASCIIToUTF16("empty")); |
| 1302 | 1302 |
| 1303 EXPECT_EQ([[bar_ buttons] count], 2U); | 1303 EXPECT_EQ([[bar_ buttons] count], 2U); |
| 1304 | 1304 |
| 1305 // First confirm mouseEntered does nothing if "menus" aren't active. | 1305 // First confirm mouseEntered does nothing if "menus" aren't active. |
| 1306 NSEvent* event = cocoa_test_event_utils::MakeMouseEvent(NSOtherMouseUp, 0); | 1306 NSEvent* event = |
| 1307 cocoa_test_event_utils::MouseEventWithType(NSOtherMouseUp, 0); |
| 1307 [bar_ mouseEnteredButton:[[bar_ buttons] objectAtIndex:0] event:event]; | 1308 [bar_ mouseEnteredButton:[[bar_ buttons] objectAtIndex:0] event:event]; |
| 1308 EXPECT_FALSE([bar_ folderController]); | 1309 EXPECT_FALSE([bar_ folderController]); |
| 1309 | 1310 |
| 1310 // Make one active. Entering it is now a no-op. | 1311 // Make one active. Entering it is now a no-op. |
| 1311 [bar_ openBookmarkFolderFromButton:[[bar_ buttons] objectAtIndex:0]]; | 1312 [bar_ openBookmarkFolderFromButton:[[bar_ buttons] objectAtIndex:0]]; |
| 1312 BookmarkBarFolderController* bbfc = [bar_ folderController]; | 1313 BookmarkBarFolderController* bbfc = [bar_ folderController]; |
| 1313 EXPECT_TRUE(bbfc); | 1314 EXPECT_TRUE(bbfc); |
| 1314 [bar_ mouseEnteredButton:[[bar_ buttons] objectAtIndex:0] event:event]; | 1315 [bar_ mouseEnteredButton:[[bar_ buttons] objectAtIndex:0] event:event]; |
| 1315 EXPECT_EQ(bbfc, [bar_ folderController]); | 1316 EXPECT_EQ(bbfc, [bar_ folderController]); |
| 1316 | 1317 |
| (...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1434 | 1435 |
| 1435 // Delete a bookmark in the off-the-side and verify it's gone. | 1436 // Delete a bookmark in the off-the-side and verify it's gone. |
| 1436 BookmarkButton* button = [bbfc buttonWithTitleEqualTo:@"DELETE_ME"]; | 1437 BookmarkButton* button = [bbfc buttonWithTitleEqualTo:@"DELETE_ME"]; |
| 1437 EXPECT_TRUE(button); | 1438 EXPECT_TRUE(button); |
| 1438 model->Remove(parent, parent->child_count() - 2); | 1439 model->Remove(parent, parent->child_count() - 2); |
| 1439 button = [bbfc buttonWithTitleEqualTo:@"DELETE_ME"]; | 1440 button = [bbfc buttonWithTitleEqualTo:@"DELETE_ME"]; |
| 1440 EXPECT_FALSE(button); | 1441 EXPECT_FALSE(button); |
| 1441 } | 1442 } |
| 1442 | 1443 |
| 1443 TEST_F(BookmarkBarControllerTest, EventToExitCheck) { | 1444 TEST_F(BookmarkBarControllerTest, EventToExitCheck) { |
| 1444 NSEvent* event = cocoa_test_event_utils::MakeMouseEvent(NSMouseMoved, 0); | 1445 NSEvent* event = cocoa_test_event_utils::MouseEventWithType(NSMouseMoved, 0); |
| 1445 EXPECT_FALSE([bar_ isEventAnExitEvent:event]); | 1446 EXPECT_FALSE([bar_ isEventAnExitEvent:event]); |
| 1446 | 1447 |
| 1447 BookmarkBarFolderWindow* folderWindow = [[[BookmarkBarFolderWindow alloc] | 1448 BookmarkBarFolderWindow* folderWindow = [[[BookmarkBarFolderWindow alloc] |
| 1448 init] autorelease]; | 1449 init] autorelease]; |
| 1449 [[[bar_ view] window] addChildWindow:folderWindow | 1450 [[[bar_ view] window] addChildWindow:folderWindow |
| 1450 ordered:NSWindowAbove]; | 1451 ordered:NSWindowAbove]; |
| 1451 event = cocoa_test_event_utils::LeftMouseDownAtPointInWindow(NSMakePoint(1,1), | 1452 event = cocoa_test_event_utils::LeftMouseDownAtPointInWindow(NSMakePoint(1,1), |
| 1452 folderWindow); | 1453 folderWindow); |
| 1453 EXPECT_FALSE([bar_ isEventAnExitEvent:event]); | 1454 EXPECT_FALSE([bar_ isEventAnExitEvent:event]); |
| 1454 | 1455 |
| (...skipping 726 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2181 "2f3b ] 4b "); | 2182 "2f3b ] 4b "); |
| 2182 actual = model_test_utils::ModelStringFromNode(root); | 2183 actual = model_test_utils::ModelStringFromNode(root); |
| 2183 EXPECT_EQ(expected, actual); | 2184 EXPECT_EQ(expected, actual); |
| 2184 | 2185 |
| 2185 // Verify that the other bookmark folder can't be deleted. | 2186 // Verify that the other bookmark folder can't be deleted. |
| 2186 BookmarkButton *otherButton = [bar_ otherBookmarksButton]; | 2187 BookmarkButton *otherButton = [bar_ otherBookmarksButton]; |
| 2187 EXPECT_FALSE([bar_ canDragBookmarkButtonToTrash:otherButton]); | 2188 EXPECT_FALSE([bar_ canDragBookmarkButtonToTrash:otherButton]); |
| 2188 } | 2189 } |
| 2189 | 2190 |
| 2190 } // namespace | 2191 } // namespace |
| OLD | NEW |