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

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: Fix MacViews bubbles 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 18 matching lines...) Expand all
29 #include "ui/base/l10n/l10n_util.h" 29 #include "ui/base/l10n/l10n_util.h"
30 #include "ui/base/l10n/l10n_util_mac.h" 30 #include "ui/base/l10n/l10n_util_mac.h"
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;
tapted 2016/08/12 04:25:39 (and here). Although the obvious flaw is that `on
40 - (void)onCheckboxChanged:(id)sender; 40 - (void)onCheckboxChanged:(id)sender;
41 @end 41 @end
42 42
43 @interface SplitBlockButton (ExposedForTesting) 43 @interface SplitBlockButton (ExposedForTesting)
44 - (NSMenu*)menu; 44 - (NSMenu*)menu;
45 @end 45 @end
46 46
47 @interface MockBubbleYesLocationBar : NSObject 47 @interface MockBubbleYesLocationBar : NSObject
48 @end 48 @end
49 49
(...skipping 317 matching lines...) Expand 10 before | Expand all | Expand 10 after
367 EXPECT_NSEQ(expected, anchor); 367 EXPECT_NSEQ(expected, anchor);
368 } 368 }
369 369
370 TEST_F(PermissionBubbleControllerTest, AnchorPositionWithoutLocationBar) { 370 TEST_F(PermissionBubbleControllerTest, AnchorPositionWithoutLocationBar) {
371 base::mac::ScopedObjCClassSwizzler locationSwizzle( 371 base::mac::ScopedObjCClassSwizzler locationSwizzle(
372 [PermissionBubbleController class], [MockBubbleNoLocationBar class], 372 [PermissionBubbleController class], [MockBubbleNoLocationBar class],
373 @selector(hasVisibleLocationBarForBrowser:)); 373 @selector(hasVisibleLocationBarForBrowser:));
374 374
375 NSPoint anchor = [controller_ getExpectedAnchorPoint]; 375 NSPoint anchor = [controller_ getExpectedAnchorPoint];
376 376
377 // Expected anchor location will be top center when there's no location bar. 377 // Expected anchor location will be top center when there's no location bar.
tapted 2016/08/12 04:25:39 nit: update comment
benwells 2016/08/12 06:29:44 Done.
benwells 2016/08/12 06:29:44 Done.
378 NSWindow* window = browser()->window()->GetNativeWindow(); 378 NSWindow* window = browser()->window()->GetNativeWindow();
379 NSRect frame = [window frame]; 379 NSRect frame = [[window contentView] frame];
380 NSPoint expected = NSMakePoint(frame.size.width / 2, frame.size.height); 380 NSPoint expected = NSMakePoint(
381 NSMinX(frame) + [PermissionBubbleController getFullscreenLeftOffset],
382 frame.size.height);
tapted 2016/08/12 04:25:39 nit: `frame.size.height` should probably be NSMaxY
benwells 2016/08/12 06:29:44 Done.
381 expected = ui::ConvertPointFromWindowToScreen(window, expected); 383 expected = ui::ConvertPointFromWindowToScreen(window, expected);
382 EXPECT_NSEQ(expected, anchor); 384 EXPECT_NSEQ(expected, anchor);
383 } 385 }
384 386
385 TEST_F(PermissionBubbleControllerTest, 387 TEST_F(PermissionBubbleControllerTest,
386 AnchorPositionDifferentWithAndWithoutLocationBar) { 388 AnchorPositionDifferentWithAndWithoutLocationBar) {
387 NSPoint withLocationBar; 389 NSPoint withLocationBar;
388 { 390 {
389 base::mac::ScopedObjCClassSwizzler locationSwizzle( 391 base::mac::ScopedObjCClassSwizzler locationSwizzle(
390 [PermissionBubbleController class], [MockBubbleYesLocationBar class], 392 [PermissionBubbleController class], [MockBubbleYesLocationBar class],
391 @selector(hasVisibleLocationBarForBrowser:)); 393 @selector(hasVisibleLocationBarForBrowser:));
392 withLocationBar = [controller_ getExpectedAnchorPoint]; 394 withLocationBar = [controller_ getExpectedAnchorPoint];
393 } 395 }
394 396
395 NSPoint withoutLocationBar; 397 NSPoint withoutLocationBar;
396 { 398 {
397 base::mac::ScopedObjCClassSwizzler locationSwizzle( 399 base::mac::ScopedObjCClassSwizzler locationSwizzle(
398 [PermissionBubbleController class], [MockBubbleNoLocationBar class], 400 [PermissionBubbleController class], [MockBubbleNoLocationBar class],
399 @selector(hasVisibleLocationBarForBrowser:)); 401 @selector(hasVisibleLocationBarForBrowser:));
400 withoutLocationBar = [controller_ getExpectedAnchorPoint]; 402 withoutLocationBar = [controller_ getExpectedAnchorPoint];
401 } 403 }
402 404
403 // The bubble should be in different places depending if the location bar is 405 // The bubble should be in different places depending if the location bar is
404 // available or not. 406 // available or not.
405 EXPECT_NSNE(withLocationBar, withoutLocationBar); 407 EXPECT_NSNE(withLocationBar, withoutLocationBar);
406 } 408 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698