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 11 matching lines...) Expand all Loading... |
22 #import "chrome/browser/ui/cocoa/bookmarks/bookmark_button_cell.h" | 22 #import "chrome/browser/ui/cocoa/bookmarks/bookmark_button_cell.h" |
23 #import "chrome/browser/ui/cocoa/bookmarks/bookmark_menu.h" | 23 #import "chrome/browser/ui/cocoa/bookmarks/bookmark_menu.h" |
24 #include "chrome/browser/ui/cocoa/browser_test_helper.h" | 24 #include "chrome/browser/ui/cocoa/browser_test_helper.h" |
25 #import "chrome/browser/ui/cocoa/cocoa_test_helper.h" | 25 #import "chrome/browser/ui/cocoa/cocoa_test_helper.h" |
26 #include "chrome/browser/ui/cocoa/test_event_utils.h" | 26 #include "chrome/browser/ui/cocoa/test_event_utils.h" |
27 #import "chrome/browser/ui/cocoa/view_resizer_pong.h" | 27 #import "chrome/browser/ui/cocoa/view_resizer_pong.h" |
28 #include "chrome/test/model_test_utils.h" | 28 #include "chrome/test/model_test_utils.h" |
29 #include "testing/gtest/include/gtest/gtest.h" | 29 #include "testing/gtest/include/gtest/gtest.h" |
30 #import "testing/gtest_mac.h" | 30 #import "testing/gtest_mac.h" |
31 #include "testing/platform_test.h" | 31 #include "testing/platform_test.h" |
| 32 #include "third_party/ocmock/gtest_support.h" |
32 #import "third_party/ocmock/OCMock/OCMock.h" | 33 #import "third_party/ocmock/OCMock/OCMock.h" |
33 #include "ui/base/theme_provider.h" | 34 #include "ui/base/theme_provider.h" |
34 | 35 |
35 // Unit tests don't need time-consuming asynchronous animations. | 36 // Unit tests don't need time-consuming asynchronous animations. |
36 @interface BookmarkBarControllerTestable : BookmarkBarController { | 37 @interface BookmarkBarControllerTestable : BookmarkBarController { |
37 } | 38 } |
38 @end | 39 @end |
39 @implementation BookmarkBarControllerTestable | 40 @implementation BookmarkBarControllerTestable |
40 - (BOOL)animationEnabled { | 41 - (BOOL)animationEnabled { |
41 return NO; | 42 return NO; |
(...skipping 1520 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1562 id origMenu = [bar_ buttonContextMenu]; | 1563 id origMenu = [bar_ buttonContextMenu]; |
1563 id fakeMenu = [OCMockObject partialMockForObject:origMenu]; | 1564 id fakeMenu = [OCMockObject partialMockForObject:origMenu]; |
1564 [[fakeMenu expect] cancelTracking]; | 1565 [[fakeMenu expect] cancelTracking]; |
1565 [bar_ setButtonContextMenu:fakeMenu]; | 1566 [bar_ setButtonContextMenu:fakeMenu]; |
1566 | 1567 |
1567 // Force a delete which should cancelTracking on the menu. | 1568 // Force a delete which should cancelTracking on the menu. |
1568 model->Remove(framma->parent(), framma->parent()->GetIndexOf(framma)); | 1569 model->Remove(framma->parent(), framma->parent()->GetIndexOf(framma)); |
1569 | 1570 |
1570 // Restore, then confirm cancelTracking was called. | 1571 // Restore, then confirm cancelTracking was called. |
1571 [bar_ setButtonContextMenu:origMenu]; | 1572 [bar_ setButtonContextMenu:origMenu]; |
1572 [fakeMenu verify]; | 1573 EXPECT_OCMOCK_VERIFY(fakeMenu); |
1573 } | 1574 } |
1574 | 1575 |
1575 TEST_F(BookmarkBarControllerTest, CloseFolderOnAnimate) { | 1576 TEST_F(BookmarkBarControllerTest, CloseFolderOnAnimate) { |
1576 BookmarkModel* model = helper_.profile()->GetBookmarkModel(); | 1577 BookmarkModel* model = helper_.profile()->GetBookmarkModel(); |
1577 const BookmarkNode* parent = model->GetBookmarkBarNode(); | 1578 const BookmarkNode* parent = model->GetBookmarkBarNode(); |
1578 const BookmarkNode* folder = model->AddFolder(parent, | 1579 const BookmarkNode* folder = model->AddFolder(parent, |
1579 parent->child_count(), | 1580 parent->child_count(), |
1580 ASCIIToUTF16("folder")); | 1581 ASCIIToUTF16("folder")); |
1581 model->AddFolder(parent, parent->child_count(), | 1582 model->AddFolder(parent, parent->child_count(), |
1582 ASCIIToUTF16("sibbling folder")); | 1583 ASCIIToUTF16("sibbling folder")); |
(...skipping 585 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2168 "2f3b ] 4b "); | 2169 "2f3b ] 4b "); |
2169 actual = model_test_utils::ModelStringFromNode(root); | 2170 actual = model_test_utils::ModelStringFromNode(root); |
2170 EXPECT_EQ(expected, actual); | 2171 EXPECT_EQ(expected, actual); |
2171 | 2172 |
2172 // Verify that the other bookmark folder can't be deleted. | 2173 // Verify that the other bookmark folder can't be deleted. |
2173 BookmarkButton *otherButton = [bar_ otherBookmarksButton]; | 2174 BookmarkButton *otherButton = [bar_ otherBookmarksButton]; |
2174 EXPECT_FALSE([bar_ canDragBookmarkButtonToTrash:otherButton]); | 2175 EXPECT_FALSE([bar_ canDragBookmarkButtonToTrash:otherButton]); |
2175 } | 2176 } |
2176 | 2177 |
2177 } // namespace | 2178 } // namespace |
OLD | NEW |