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

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

Issue 1547010: Set bookmark bar menu windows to the correct level.... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 10 years, 8 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/browser/cocoa/bookmark_bar_folder_controller.mm ('k') | no next file » | 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) 2010 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2010 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/scoped_nsobject.h" 8 #include "base/scoped_nsobject.h"
9 #import "chrome/browser/cocoa/bookmark_bar_controller.h" 9 #import "chrome/browser/cocoa/bookmark_bar_controller.h"
10 #import "chrome/browser/cocoa/bookmark_bar_folder_controller.h" 10 #import "chrome/browser/cocoa/bookmark_bar_folder_controller.h"
11 #include "chrome/browser/cocoa/browser_test_helper.h" 11 #include "chrome/browser/cocoa/browser_test_helper.h"
12 #import "chrome/browser/cocoa/cocoa_test_helper.h" 12 #import "chrome/browser/cocoa/cocoa_test_helper.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 15
16 // Add a redirect to make testing easier. 16 // Add a redirect to make testing easier.
17 @interface BookmarkBarFolderController(MakeTestingEasier) 17 @interface BookmarkBarFolderController(MakeTestingEasier)
18 - (IBAction)openBookmarkFolderFromButton:(id)sender; 18 - (IBAction)openBookmarkFolderFromButton:(id)sender;
19 @end 19 @end
20 20
21 @implementation BookmarkBarFolderController(MakeTestingEasier) 21 @implementation BookmarkBarFolderController(MakeTestingEasier)
22 - (IBAction)openBookmarkFolderFromButton:(id)sender { 22 - (IBAction)openBookmarkFolderFromButton:(id)sender {
23 [[self folderTarget] openBookmarkFolderFromButton:sender]; 23 [[self folderTarget] openBookmarkFolderFromButton:sender];
24 } 24 }
25 @end 25 @end
26 26
27 // Don't use a high window level when running unit tests -- it'll
28 // interfere with anything else you are working on.
29 @interface BookmarkBarFolderControllerLow : BookmarkBarFolderController
30 @end
31
32 @implementation BookmarkBarFolderControllerLow
33 - (void)configureWindowLevel {
34 // Intentionally empty.
35 }
36 @end
37
27 38
28 @interface BookmarkBarFolderControllerPong : BookmarkBarFolderController { 39 @interface BookmarkBarFolderControllerPong : BookmarkBarFolderController {
29 BOOL childFolderWillShow_; 40 BOOL childFolderWillShow_;
30 BOOL childFolderWillClose_; 41 BOOL childFolderWillClose_;
31 } 42 }
32 @property(readonly) BOOL childFolderWillShow; 43 @property(readonly) BOOL childFolderWillShow;
33 @property(readonly) BOOL childFolderWillClose; 44 @property(readonly) BOOL childFolderWillClose;
34 @end 45 @end
35 46
36 @implementation BookmarkBarFolderControllerPong 47 @implementation BookmarkBarFolderControllerPong
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after
148 [[bbfc window] close]; // trigger an autorelease of bbfc.get() 159 [[bbfc window] close]; // trigger an autorelease of bbfc.get()
149 } 160 }
150 161
151 TEST_F(BookmarkBarFolderControllerTest, Position) { 162 TEST_F(BookmarkBarFolderControllerTest, Position) {
152 BookmarkButton* parentButton = [[parentBarController_ buttons] 163 BookmarkButton* parentButton = [[parentBarController_ buttons]
153 objectAtIndex:0]; 164 objectAtIndex:0];
154 EXPECT_TRUE(parentButton); 165 EXPECT_TRUE(parentButton);
155 166
156 // If parent is a BookmarkBarController, grow down. 167 // If parent is a BookmarkBarController, grow down.
157 scoped_nsobject<BookmarkBarFolderController> bbfc; 168 scoped_nsobject<BookmarkBarFolderController> bbfc;
158 bbfc.reset([[BookmarkBarFolderController alloc] 169 bbfc.reset([[BookmarkBarFolderControllerLow alloc]
159 initWithParentButton:parentButton 170 initWithParentButton:parentButton
160 parentController:parentBarController_]); 171 parentController:parentBarController_]);
161 NSPoint pt = [bbfc windowTopLeft]; 172 NSPoint pt = [bbfc windowTopLeft];
162 EXPECT_EQ(pt.y, NSMinY([[parentBarController_ view] frame])); 173 EXPECT_EQ(pt.y, NSMinY([[parentBarController_ view] frame]));
163 174
164 // If parent is a BookmarkBarFolderController, grow right. 175 // If parent is a BookmarkBarFolderController, grow right.
165 scoped_nsobject<BookmarkBarFolderController> bbfc2; 176 scoped_nsobject<BookmarkBarFolderController> bbfc2;
166 bbfc2.reset([[BookmarkBarFolderController alloc] 177 bbfc2.reset([[BookmarkBarFolderControllerLow alloc]
167 initWithParentButton:[[bbfc buttons] objectAtIndex:0] 178 initWithParentButton:[[bbfc buttons] objectAtIndex:0]
168 parentController:bbfc.get()]); 179 parentController:bbfc.get()]);
169 pt = [bbfc2 windowTopLeft]; 180 pt = [bbfc2 windowTopLeft];
170 EXPECT_EQ(pt.x, NSMaxX([[[bbfc.get() window] contentView] frame])); 181 EXPECT_EQ(pt.x, NSMaxX([[[bbfc.get() window] contentView] frame]));
171 } 182 }
172 183
173 TEST_F(BookmarkBarFolderControllerTest, DropDestination) { 184 TEST_F(BookmarkBarFolderControllerTest, DropDestination) {
174 scoped_nsobject<BookmarkBarFolderController> bbfc; 185 scoped_nsobject<BookmarkBarFolderController> bbfc;
175 bbfc.reset(SimpleBookmarkBarFolderController()); 186 bbfc.reset(SimpleBookmarkBarFolderController());
176 EXPECT_TRUE(bbfc.get()); 187 EXPECT_TRUE(bbfc.get());
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after
283 } 294 }
284 295
285 296
286 297
287 // TODO(jrg): draggingEntered: and draggingExited: trigger timers so 298 // TODO(jrg): draggingEntered: and draggingExited: trigger timers so
288 // they are hard to test. Factor out "fire timers" into routines 299 // they are hard to test. Factor out "fire timers" into routines
289 // which can be overridden to fire immediately to make behavior 300 // which can be overridden to fire immediately to make behavior
290 // confirmable. 301 // confirmable.
291 // There is a similar problem with mouseEnteredButton: and 302 // There is a similar problem with mouseEnteredButton: and
292 // mouseExitedButton:. 303 // mouseExitedButton:.
OLDNEW
« no previous file with comments | « chrome/browser/cocoa/bookmark_bar_folder_controller.mm ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698