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

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

Issue 194110: Convert the AutocompletePopupPositioner into a BubblePositioner in preparatio... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 11 years, 3 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
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 #import <Cocoa/Cocoa.h> 5 #import <Cocoa/Cocoa.h>
6 6
7 #import "base/scoped_nsobject.h" 7 #import "base/scoped_nsobject.h"
8 #include "chrome/app/chrome_dll_resource.h" 8 #include "chrome/app/chrome_dll_resource.h"
9 #include "chrome/browser/cocoa/browser_test_helper.h" 9 #include "chrome/browser/cocoa/browser_test_helper.h"
10 #import "chrome/browser/cocoa/cocoa_test_helper.h" 10 #import "chrome/browser/cocoa/cocoa_test_helper.h"
(...skipping 255 matching lines...) Expand 10 before | Expand all | Expand 10 after
266 } 266 }
267 267
268 TEST_F(ToolbarControllerTest, StarButtonInWindowCoordinates) { 268 TEST_F(ToolbarControllerTest, StarButtonInWindowCoordinates) {
269 NSRect star = [bar_ starButtonInWindowCoordinates]; 269 NSRect star = [bar_ starButtonInWindowCoordinates];
270 NSRect all = [[[bar_ view] window] frame]; 270 NSRect all = [[[bar_ view] window] frame];
271 271
272 // Make sure the star is completely inside the window rect 272 // Make sure the star is completely inside the window rect
273 EXPECT_TRUE(NSContainsRect(all, star)); 273 EXPECT_TRUE(NSContainsRect(all, star));
274 } 274 }
275 275
276 TEST_F(ToolbarControllerTest, AutocompletePopupPosition) { 276 TEST_F(ToolbarControllerTest, BubblePosition) {
277 NSView* locationBar = [[bar_ toolbarViews] objectAtIndex:kLocationIndex]; 277 NSView* locationBar = [[bar_ toolbarViews] objectAtIndex:kLocationIndex];
278 278
279 // The window frame (in window base coordinates). 279 // The window frame (in window base coordinates).
280 NSRect all = [[[bar_ view] window] frame]; 280 NSRect all = [[[bar_ view] window] frame];
281 // The frame of the location bar in window base coordinates. 281 // The frame of the location bar in window base coordinates.
282 NSRect locationFrame = 282 NSRect locationFrame =
283 [locationBar convertRect:[locationBar bounds] toView:nil]; 283 [locationBar convertRect:[locationBar bounds] toView:nil];
284 // The frame of the popup in window base coordinates. 284 // The frame of the location stack in window base coordinates. The horizontal
285 gfx::Rect popupFrame = [bar_ autocompletePopupPosition]; 285 // coordinates here are used for the omnibox dropdown.
286 gfx::Rect locationStackFrame = [bar_ locationStackBounds];
286 287
287 // Make sure the popup starts to the left of and ends to the right of the 288 // Make sure the location stack starts to the left of and ends to the right of
288 // location bar. 289 // the location bar.
289 EXPECT_LT(popupFrame.x(), NSMinX(locationFrame)); 290 EXPECT_LT(locationStackFrame.x(), NSMinX(locationFrame));
290 EXPECT_GT(popupFrame.right(), NSMaxX(locationFrame)); 291 EXPECT_GT(locationStackFrame.right(), NSMaxX(locationFrame));
291
292 // Make sure the popup frame is positioned above the bottom of the
293 // location bar.
294 EXPECT_GE(popupFrame.bottom(), NSMinY(locationFrame));
295 } 292 }
296 293
297 TEST_F(ToolbarControllerTest, HoverButtonForEvent) { 294 TEST_F(ToolbarControllerTest, HoverButtonForEvent) {
298 scoped_nsobject<HitView> view([[HitView alloc] 295 scoped_nsobject<HitView> view([[HitView alloc]
299 initWithFrame:NSMakeRect(0,0,100,100)]); 296 initWithFrame:NSMakeRect(0,0,100,100)]);
300 [bar_ setView:view]; 297 [bar_ setView:view];
301 NSEvent* event = [NSEvent mouseEventWithType:NSMouseMoved 298 NSEvent* event = [NSEvent mouseEventWithType:NSMouseMoved
302 location:NSMakePoint(10,10) 299 location:NSMakePoint(10,10)
303 modifierFlags:0 300 modifierFlags:0
304 timestamp:0 301 timestamp:0
(...skipping 13 matching lines...) Expand all
318 EXPECT_FALSE([bar_ hoverButtonForEvent:event]); 315 EXPECT_FALSE([bar_ hoverButtonForEvent:event]);
319 316
320 // Now! 317 // Now!
321 scoped_nsobject<GradientButtonCell> cell([[GradientButtonCell alloc] init]); 318 scoped_nsobject<GradientButtonCell> cell([[GradientButtonCell alloc] init]);
322 [button setCell:cell.get()]; 319 [button setCell:cell.get()];
323 EXPECT_TRUE([bar_ hoverButtonForEvent:nil]); 320 EXPECT_TRUE([bar_ hoverButtonForEvent:nil]);
324 } 321 }
325 322
326 323
327 } // namespace 324 } // namespace
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698