OLD | NEW |
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009 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/cocoa/bookmark_bar_bridge.h" | 5 #include "chrome/browser/cocoa/bookmark_bar_bridge.h" |
6 #include "chrome/browser/cocoa/bookmark_bar_controller.h" | 6 #include "chrome/browser/cocoa/bookmark_bar_controller.h" |
7 #include "chrome/browser/cocoa/browser_test_helper.h" | 7 #include "chrome/browser/cocoa/browser_test_helper.h" |
8 #include "chrome/browser/cocoa/cocoa_test_helper.h" | 8 #include "chrome/browser/cocoa/cocoa_test_helper.h" |
9 #include "testing/gtest/include/gtest/gtest.h" | 9 #include "testing/gtest/include/gtest/gtest.h" |
10 | 10 |
(...skipping 16 matching lines...) Expand all Loading... |
27 @public | 27 @public |
28 scoped_nsobject<NSMutableArray> callbacks_; | 28 scoped_nsobject<NSMutableArray> callbacks_; |
29 std::vector<OpenInfo> opens_; | 29 std::vector<OpenInfo> opens_; |
30 } | 30 } |
31 @end | 31 @end |
32 | 32 |
33 @implementation FakeBookmarkBarController | 33 @implementation FakeBookmarkBarController |
34 | 34 |
35 - (id)initWithProfile:(Profile*)profile | 35 - (id)initWithProfile:(Profile*)profile |
36 parentView:(NSView*)parentView | 36 parentView:(NSView*)parentView |
37 webContentView:(NSView*)webContentView { | 37 webContentView:(NSView*)webContentView |
| 38 infoBarsView:(NSView*)infoBarsView { |
38 if ((self = [super initWithProfile:profile | 39 if ((self = [super initWithProfile:profile |
39 parentView:parentView | 40 parentView:parentView |
40 webContentView:webContentView | 41 webContentView:webContentView |
| 42 infoBarsView:infoBarsView |
41 delegate:self])) { | 43 delegate:self])) { |
42 callbacks_.reset([[NSMutableArray alloc] init]); | 44 callbacks_.reset([[NSMutableArray alloc] init]); |
43 } | 45 } |
44 return self; | 46 return self; |
45 } | 47 } |
46 | 48 |
47 - (void)loaded:(BookmarkModel*)model { | 49 - (void)loaded:(BookmarkModel*)model { |
48 [callbacks_ addObject:[NSNumber numberWithInt:0]]; | 50 [callbacks_ addObject:[NSNumber numberWithInt:0]]; |
49 } | 51 } |
50 | 52 |
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
106 | 108 |
107 // Call all the callbacks; make sure they are all redirected to the objc object. | 109 // Call all the callbacks; make sure they are all redirected to the objc object. |
108 TEST_F(BookmarkBarBridgeTest, TestRedirect) { | 110 TEST_F(BookmarkBarBridgeTest, TestRedirect) { |
109 Profile *profile = browser_test_helper_.profile(); | 111 Profile *profile = browser_test_helper_.profile(); |
110 BookmarkModel *model = profile->GetBookmarkModel(); | 112 BookmarkModel *model = profile->GetBookmarkModel(); |
111 | 113 |
112 scoped_nsobject<NSView> parentView([[NSView alloc] | 114 scoped_nsobject<NSView> parentView([[NSView alloc] |
113 initWithFrame:NSMakeRect(0,0,100,100)]); | 115 initWithFrame:NSMakeRect(0,0,100,100)]); |
114 scoped_nsobject<NSView> webView([[NSView alloc] | 116 scoped_nsobject<NSView> webView([[NSView alloc] |
115 initWithFrame:NSMakeRect(0,0,100,100)]); | 117 initWithFrame:NSMakeRect(0,0,100,100)]); |
| 118 scoped_nsobject<NSView> infoBarsView( |
| 119 [[NSView alloc] initWithFrame:NSMakeRect(0,0,100,100)]); |
116 | 120 |
117 scoped_nsobject<FakeBookmarkBarController> | 121 scoped_nsobject<FakeBookmarkBarController> |
118 controller([[FakeBookmarkBarController alloc] | 122 controller([[FakeBookmarkBarController alloc] |
119 initWithProfile:profile | 123 initWithProfile:profile |
120 parentView:parentView.get() | 124 parentView:parentView.get() |
121 webContentView:webView.get()]); | 125 webContentView:webView.get() |
| 126 infoBarsView:infoBarsView.get()]); |
122 EXPECT_TRUE(controller.get()); | 127 EXPECT_TRUE(controller.get()); |
123 scoped_ptr<BookmarkBarBridge> bridge(new BookmarkBarBridge(controller.get(), | 128 scoped_ptr<BookmarkBarBridge> bridge(new BookmarkBarBridge(controller.get(), |
124 model)); | 129 model)); |
125 EXPECT_TRUE(bridge.get()); | 130 EXPECT_TRUE(bridge.get()); |
126 | 131 |
127 bridge->Loaded(NULL); | 132 bridge->Loaded(NULL); |
128 bridge->BookmarkModelBeingDeleted(NULL); | 133 bridge->BookmarkModelBeingDeleted(NULL); |
129 bridge->BookmarkNodeMoved(NULL, NULL, 0, NULL, 0); | 134 bridge->BookmarkNodeMoved(NULL, NULL, 0, NULL, 0); |
130 bridge->BookmarkNodeAdded(NULL, NULL, 0); | 135 bridge->BookmarkNodeAdded(NULL, NULL, 0); |
131 bridge->BookmarkNodeChanged(NULL, NULL); | 136 bridge->BookmarkNodeChanged(NULL, NULL); |
132 bridge->BookmarkNodeFavIconLoaded(NULL, NULL); | 137 bridge->BookmarkNodeFavIconLoaded(NULL, NULL); |
133 bridge->BookmarkNodeChildrenReordered(NULL, NULL); | 138 bridge->BookmarkNodeChildrenReordered(NULL, NULL); |
134 bridge->BookmarkNodeRemoved(NULL, NULL, 0, NULL); | 139 bridge->BookmarkNodeRemoved(NULL, NULL, 0, NULL); |
135 | 140 |
136 // 8 calls above plus an initial Loaded() in init routine makes 9 | 141 // 8 calls above plus an initial Loaded() in init routine makes 9 |
137 EXPECT_TRUE([controller.get()->callbacks_ count] == 9); | 142 EXPECT_TRUE([controller.get()->callbacks_ count] == 9); |
138 | 143 |
139 for (int x = 1; x < 9; x++) { | 144 for (int x = 1; x < 9; x++) { |
140 NSNumber *num = [NSNumber numberWithInt:x-1]; | 145 NSNumber *num = [NSNumber numberWithInt:x-1]; |
141 EXPECT_TRUE([[controller.get()->callbacks_ objectAtIndex:x] isEqual:num]); | 146 EXPECT_TRUE([[controller.get()->callbacks_ objectAtIndex:x] isEqual:num]); |
142 } | 147 } |
143 } | 148 } |
OLD | NEW |