Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(138)

Side by Side Diff: chrome/browser/cocoa/bookmark_bar_bridge_unittest.mm

Issue 159776: Rewrites the Mac view resizing logic to have the BrowserWindowController... (Closed) Base URL: http://src.chromium.org/svn/trunk/src/
Patch Set: '' Created 11 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « chrome/app/nibs/InfoBarContainer.xib ('k') | chrome/browser/cocoa/bookmark_bar_controller.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 14 matching lines...) Expand all
25 @interface FakeBookmarkBarController : 25 @interface FakeBookmarkBarController :
26 BookmarkBarController<BookmarkURLOpener> { 26 BookmarkBarController<BookmarkURLOpener> {
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
37 webContentView:(NSView*)webContentView
38 infoBarsView:(NSView*)infoBarsView {
39 if ((self = [super initWithProfile:profile 36 if ((self = [super initWithProfile:profile
40 parentView:parentView 37 initialWidth:100 // arbitrary
41 webContentView:webContentView 38 resizeDelegate:nil
42 infoBarsView:infoBarsView 39 urlDelegate:self])) {
43 delegate:self])) {
44 callbacks_.reset([[NSMutableArray alloc] init]); 40 callbacks_.reset([[NSMutableArray alloc] init]);
45 } 41 }
46 return self; 42 return self;
47 } 43 }
48 44
49 - (void)loaded:(BookmarkModel*)model { 45 - (void)loaded:(BookmarkModel*)model {
50 [callbacks_ addObject:[NSNumber numberWithInt:0]]; 46 [callbacks_ addObject:[NSNumber numberWithInt:0]];
51 } 47 }
52 48
53 - (void)beingDeleted:(BookmarkModel*)model { 49 - (void)beingDeleted:(BookmarkModel*)model {
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
89 - (void)openBookmarkURL:(const GURL&)url 85 - (void)openBookmarkURL:(const GURL&)url
90 disposition:(WindowOpenDisposition)disposition { 86 disposition:(WindowOpenDisposition)disposition {
91 opens_.push_back(OpenInfo(url, disposition)); 87 opens_.push_back(OpenInfo(url, disposition));
92 } 88 }
93 89
94 @end 90 @end
95 91
96 92
97 class BookmarkBarBridgeTest : public testing::Test { 93 class BookmarkBarBridgeTest : public testing::Test {
98 public: 94 public:
99 BookmarkBarBridgeTest() {
100 NSRect content_frame = NSMakeRect(0, 0, 100, 100);
101 view_.reset([[NSView alloc] initWithFrame:content_frame]);
102 }
103
104 CocoaTestHelper cocoa_helper_; 95 CocoaTestHelper cocoa_helper_;
105 BrowserTestHelper browser_test_helper_; 96 BrowserTestHelper browser_test_helper_;
106 scoped_nsobject<NSView> view_;
107 }; 97 };
108 98
109 // Call all the callbacks; make sure they are all redirected to the objc object. 99 // Call all the callbacks; make sure they are all redirected to the objc object.
110 TEST_F(BookmarkBarBridgeTest, TestRedirect) { 100 TEST_F(BookmarkBarBridgeTest, TestRedirect) {
111 Profile *profile = browser_test_helper_.profile(); 101 Profile *profile = browser_test_helper_.profile();
112 BookmarkModel *model = profile->GetBookmarkModel(); 102 BookmarkModel *model = profile->GetBookmarkModel();
113 103
114 scoped_nsobject<NSView> parentView([[NSView alloc] 104 scoped_nsobject<NSView> parentView([[NSView alloc]
115 initWithFrame:NSMakeRect(0,0,100,100)]); 105 initWithFrame:NSMakeRect(0,0,100,100)]);
116 scoped_nsobject<NSView> webView([[NSView alloc] 106 scoped_nsobject<NSView> webView([[NSView alloc]
117 initWithFrame:NSMakeRect(0,0,100,100)]); 107 initWithFrame:NSMakeRect(0,0,100,100)]);
118 scoped_nsobject<NSView> infoBarsView( 108 scoped_nsobject<NSView> infoBarsView(
119 [[NSView alloc] initWithFrame:NSMakeRect(0,0,100,100)]); 109 [[NSView alloc] initWithFrame:NSMakeRect(0,0,100,100)]);
120 110
121 scoped_nsobject<FakeBookmarkBarController> 111 scoped_nsobject<FakeBookmarkBarController>
122 controller([[FakeBookmarkBarController alloc] 112 controller([[FakeBookmarkBarController alloc] initWithProfile:profile]);
123 initWithProfile:profile
124 parentView:parentView.get()
125 webContentView:webView.get()
126 infoBarsView:infoBarsView.get()]);
127 EXPECT_TRUE(controller.get()); 113 EXPECT_TRUE(controller.get());
128 scoped_ptr<BookmarkBarBridge> bridge(new BookmarkBarBridge(controller.get(), 114 scoped_ptr<BookmarkBarBridge> bridge(new BookmarkBarBridge(controller.get(),
129 model)); 115 model));
130 EXPECT_TRUE(bridge.get()); 116 EXPECT_TRUE(bridge.get());
131 117
132 bridge->Loaded(NULL); 118 bridge->Loaded(NULL);
133 bridge->BookmarkModelBeingDeleted(NULL); 119 bridge->BookmarkModelBeingDeleted(NULL);
134 bridge->BookmarkNodeMoved(NULL, NULL, 0, NULL, 0); 120 bridge->BookmarkNodeMoved(NULL, NULL, 0, NULL, 0);
135 bridge->BookmarkNodeAdded(NULL, NULL, 0); 121 bridge->BookmarkNodeAdded(NULL, NULL, 0);
136 bridge->BookmarkNodeChanged(NULL, NULL); 122 bridge->BookmarkNodeChanged(NULL, NULL);
137 bridge->BookmarkNodeFavIconLoaded(NULL, NULL); 123 bridge->BookmarkNodeFavIconLoaded(NULL, NULL);
138 bridge->BookmarkNodeChildrenReordered(NULL, NULL); 124 bridge->BookmarkNodeChildrenReordered(NULL, NULL);
139 bridge->BookmarkNodeRemoved(NULL, NULL, 0, NULL); 125 bridge->BookmarkNodeRemoved(NULL, NULL, 0, NULL);
140 126
141 // 8 calls above plus an initial Loaded() in init routine makes 9 127 // 8 calls above plus an initial Loaded() in init routine makes 9
142 EXPECT_TRUE([controller.get()->callbacks_ count] == 9); 128 EXPECT_TRUE([controller.get()->callbacks_ count] == 9);
143 129
144 for (int x = 1; x < 9; x++) { 130 for (int x = 1; x < 9; x++) {
145 NSNumber *num = [NSNumber numberWithInt:x-1]; 131 NSNumber *num = [NSNumber numberWithInt:x-1];
146 EXPECT_TRUE([[controller.get()->callbacks_ objectAtIndex:x] isEqual:num]); 132 EXPECT_TRUE([[controller.get()->callbacks_ objectAtIndex:x] isEqual:num]);
147 } 133 }
148 } 134 }
OLDNEW
« no previous file with comments | « chrome/app/nibs/InfoBarContainer.xib ('k') | chrome/browser/cocoa/bookmark_bar_controller.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698