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 "chrome/browser/bookmarks/bookmark_model_factory.h" | 5 #include "chrome/browser/bookmarks/bookmark_model_factory.h" |
6 #import "chrome/browser/ui/cocoa/bookmarks/bookmark_bar_controller.h" | 6 #import "chrome/browser/ui/cocoa/bookmarks/bookmark_bar_controller.h" |
7 #import "chrome/browser/ui/cocoa/bookmarks/bookmark_bar_folder_controller.h" | 7 #import "chrome/browser/ui/cocoa/bookmarks/bookmark_bar_folder_controller.h" |
8 #include "chrome/browser/ui/cocoa/bookmarks/bookmark_button.h" | 8 #include "chrome/browser/ui/cocoa/bookmarks/bookmark_button.h" |
9 #import "chrome/browser/ui/cocoa/bookmarks/bookmark_folder_target.h" | 9 #import "chrome/browser/ui/cocoa/bookmarks/bookmark_folder_target.h" |
10 #include "chrome/browser/ui/cocoa/test/cocoa_profile_test.h" | 10 #include "chrome/browser/ui/cocoa/test/cocoa_profile_test.h" |
11 #include "chrome/test/base/testing_profile.h" | 11 #include "chrome/test/base/testing_profile.h" |
12 #include "components/bookmarks/browser/bookmark_model.h" | 12 #include "components/bookmarks/browser/bookmark_model.h" |
13 #include "testing/gtest/include/gtest/gtest.h" | 13 #include "testing/gtest/include/gtest/gtest.h" |
14 #include "testing/platform_test.h" | 14 #include "testing/platform_test.h" |
15 #import "third_party/ocmock/OCMock/OCMock.h" | 15 #import "third_party/ocmock/OCMock/OCMock.h" |
16 #include "third_party/ocmock/gtest_support.h" | 16 #include "third_party/ocmock/gtest_support.h" |
17 | 17 |
18 using bookmarks::BookmarkModel; | 18 using bookmarks::BookmarkModel; |
19 using bookmarks::BookmarkNode; | 19 using bookmarks::BookmarkNode; |
20 | 20 |
21 @interface OCMockObject(PreventRetainCycle) | 21 @interface OCMockObject(PreventRetainCycle) |
22 - (void)clearRecordersAndExpectations; | 22 - (void)clearRecordersAndExpectations; |
23 @end | 23 @end |
24 | 24 |
25 @implementation OCMockObject(PreventRetainCycle) | 25 @implementation OCMockObject(PreventRetainCycle) |
26 | 26 |
27 // We need a mechanism to clear the invocation handlers to break a | 27 // We need a mechanism to clear the invocation handlers to break a |
28 // retain cycle (see below; search for "retain cycle"). | 28 // retain cycle (see below; search for "retain cycle"). |
29 - (void)clearRecordersAndExpectations { | 29 - (void)clearRecordersAndExpectations { |
30 [recorders removeAllObjects]; | 30 [stubs removeAllObjects]; |
31 [expectations removeAllObjects]; | 31 [expectations removeAllObjects]; |
32 } | 32 } |
33 | 33 |
34 @end | 34 @end |
35 | 35 |
36 | 36 |
37 class BookmarkFolderTargetTest : public CocoaProfileTest { | 37 class BookmarkFolderTargetTest : public CocoaProfileTest { |
38 public: | 38 public: |
39 void SetUp() override { | 39 void SetUp() override { |
40 CocoaProfileTest::SetUp(); | 40 CocoaProfileTest::SetUp(); |
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
121 base::scoped_nsobject<BookmarkFolderTarget> target( | 121 base::scoped_nsobject<BookmarkFolderTarget> target( |
122 [[BookmarkFolderTarget alloc] initWithController:controller | 122 [[BookmarkFolderTarget alloc] initWithController:controller |
123 profile:profile()]); | 123 profile:profile()]); |
124 | 124 |
125 [target openBookmarkFolderFromButton:sender]; | 125 [target openBookmarkFolderFromButton:sender]; |
126 EXPECT_OCMOCK_VERIFY(controller); | 126 EXPECT_OCMOCK_VERIFY(controller); |
127 | 127 |
128 // Break retain cycles. | 128 // Break retain cycles. |
129 [controller clearRecordersAndExpectations]; | 129 [controller clearRecordersAndExpectations]; |
130 } | 130 } |
OLD | NEW |