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

Side by Side Diff: chrome/browser/ui/cocoa/website_settings/permission_bubble_controller_unittest.mm

Issue 2233293003: Position Mac permission bubbles on the left when in fullscreen. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Nits Created 4 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
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 "chrome/browser/ui/cocoa/website_settings/permission_bubble_controller.h " 5 #import "chrome/browser/ui/cocoa/website_settings/permission_bubble_controller.h "
6 6
7 #include <Carbon/Carbon.h> 7 #include <Carbon/Carbon.h>
8 8
9 #include "base/mac/foundation_util.h" 9 #include "base/mac/foundation_util.h"
10 #import "base/mac/scoped_objc_class_swizzler.h" 10 #import "base/mac/scoped_objc_class_swizzler.h"
(...skipping 20 matching lines...) Expand all
31 #import "ui/events/test/cocoa_test_event_utils.h" 31 #import "ui/events/test/cocoa_test_event_utils.h"
32 32
33 @class ConstrainedWindowButton; 33 @class ConstrainedWindowButton;
34 34
35 @interface PermissionBubbleController (ExposedForTesting) 35 @interface PermissionBubbleController (ExposedForTesting)
36 - (void)ok:(id)sender; 36 - (void)ok:(id)sender;
37 - (void)onAllow:(id)sender; 37 - (void)onAllow:(id)sender;
38 - (void)onBlock:(id)sender; 38 - (void)onBlock:(id)sender;
39 - (void)onCustomize:(id)sender; 39 - (void)onCustomize:(id)sender;
40 - (void)onCheckboxChanged:(id)sender; 40 - (void)onCheckboxChanged:(id)sender;
41 + (NSInteger)getFullscreenLeftOffset;
41 @end 42 @end
42 43
43 @interface SplitBlockButton (ExposedForTesting) 44 @interface SplitBlockButton (ExposedForTesting)
44 - (NSMenu*)menu; 45 - (NSMenu*)menu;
45 @end 46 @end
46 47
47 @interface MockBubbleYesLocationBar : NSObject 48 @interface MockBubbleYesLocationBar : NSObject
48 @end 49 @end
49 50
50 @implementation MockBubbleYesLocationBar 51 @implementation MockBubbleYesLocationBar
(...skipping 316 matching lines...) Expand 10 before | Expand all | Expand 10 after
367 EXPECT_NSEQ(expected, anchor); 368 EXPECT_NSEQ(expected, anchor);
368 } 369 }
369 370
370 TEST_F(PermissionBubbleControllerTest, AnchorPositionWithoutLocationBar) { 371 TEST_F(PermissionBubbleControllerTest, AnchorPositionWithoutLocationBar) {
371 base::mac::ScopedObjCClassSwizzler locationSwizzle( 372 base::mac::ScopedObjCClassSwizzler locationSwizzle(
372 [PermissionBubbleController class], [MockBubbleNoLocationBar class], 373 [PermissionBubbleController class], [MockBubbleNoLocationBar class],
373 @selector(hasVisibleLocationBarForBrowser:)); 374 @selector(hasVisibleLocationBarForBrowser:));
374 375
375 NSPoint anchor = [controller_ getExpectedAnchorPoint]; 376 NSPoint anchor = [controller_ getExpectedAnchorPoint];
376 377
377 // Expected anchor location will be top center when there's no location bar. 378 // Expected anchor location will be top left when there's no location bar.
378 NSWindow* window = browser()->window()->GetNativeWindow(); 379 NSWindow* window = browser()->window()->GetNativeWindow();
379 NSRect frame = [window frame]; 380 NSRect frame = [[window contentView] frame];
380 NSPoint expected = NSMakePoint(frame.size.width / 2, frame.size.height); 381 NSPoint expected = NSMakePoint(
382 NSMinX(frame) + [PermissionBubbleController getFullscreenLeftOffset],
383 NSMaxY(frame));
381 expected = ui::ConvertPointFromWindowToScreen(window, expected); 384 expected = ui::ConvertPointFromWindowToScreen(window, expected);
382 EXPECT_NSEQ(expected, anchor); 385 EXPECT_NSEQ(expected, anchor);
383 } 386 }
384 387
385 TEST_F(PermissionBubbleControllerTest, 388 TEST_F(PermissionBubbleControllerTest,
386 AnchorPositionDifferentWithAndWithoutLocationBar) { 389 AnchorPositionDifferentWithAndWithoutLocationBar) {
387 NSPoint withLocationBar; 390 NSPoint withLocationBar;
388 { 391 {
389 base::mac::ScopedObjCClassSwizzler locationSwizzle( 392 base::mac::ScopedObjCClassSwizzler locationSwizzle(
390 [PermissionBubbleController class], [MockBubbleYesLocationBar class], 393 [PermissionBubbleController class], [MockBubbleYesLocationBar class],
391 @selector(hasVisibleLocationBarForBrowser:)); 394 @selector(hasVisibleLocationBarForBrowser:));
392 withLocationBar = [controller_ getExpectedAnchorPoint]; 395 withLocationBar = [controller_ getExpectedAnchorPoint];
393 } 396 }
394 397
395 NSPoint withoutLocationBar; 398 NSPoint withoutLocationBar;
396 { 399 {
397 base::mac::ScopedObjCClassSwizzler locationSwizzle( 400 base::mac::ScopedObjCClassSwizzler locationSwizzle(
398 [PermissionBubbleController class], [MockBubbleNoLocationBar class], 401 [PermissionBubbleController class], [MockBubbleNoLocationBar class],
399 @selector(hasVisibleLocationBarForBrowser:)); 402 @selector(hasVisibleLocationBarForBrowser:));
400 withoutLocationBar = [controller_ getExpectedAnchorPoint]; 403 withoutLocationBar = [controller_ getExpectedAnchorPoint];
401 } 404 }
402 405
403 // The bubble should be in different places depending if the location bar is 406 // The bubble should be in different places depending if the location bar is
404 // available or not. 407 // available or not.
405 EXPECT_NSNE(withLocationBar, withoutLocationBar); 408 EXPECT_NSNE(withLocationBar, withoutLocationBar);
406 } 409 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698