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

Side by Side Diff: chrome/browser/ui/cocoa/extensions/extension_message_bubble_browsertest_mac.mm

Issue 1775223002: Prepare chrome/ for compilation with OS X 10.7 deployment target. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Compile errors. Fix null-window error. Created 4 years, 9 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 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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 "base/macros.h" 5 #include "base/macros.h"
6 #include "chrome/browser/ui/browser_window.h" 6 #include "chrome/browser/ui/browser_window.h"
7 #import "chrome/browser/ui/cocoa/browser_window_controller.h" 7 #import "chrome/browser/ui/cocoa/browser_window_controller.h"
8 #import "chrome/browser/ui/cocoa/extensions/browser_action_button.h" 8 #import "chrome/browser/ui/cocoa/extensions/browser_action_button.h"
9 #import "chrome/browser/ui/cocoa/extensions/browser_actions_controller.h" 9 #import "chrome/browser/ui/cocoa/extensions/browser_actions_controller.h"
10 #import "chrome/browser/ui/cocoa/extensions/toolbar_actions_bar_bubble_mac.h" 10 #import "chrome/browser/ui/cocoa/extensions/toolbar_actions_bar_bubble_mac.h"
11 #import "chrome/browser/ui/cocoa/toolbar/toolbar_controller.h" 11 #import "chrome/browser/ui/cocoa/toolbar/toolbar_controller.h"
12 #include "chrome/browser/ui/extensions/extension_message_bubble_browsertest.h" 12 #include "chrome/browser/ui/extensions/extension_message_bubble_browsertest.h"
13 #include "ui/base/cocoa/cocoa_base_utils.h"
13 14
14 namespace { 15 namespace {
15 16
16 // Returns the ToolbarController for the given browser. 17 // Returns the ToolbarController for the given browser.
17 ToolbarController* ToolbarControllerForBrowser(Browser* browser) { 18 ToolbarController* ToolbarControllerForBrowser(Browser* browser) {
18 return [[BrowserWindowController browserWindowControllerForWindow: 19 return [[BrowserWindowController browserWindowControllerForWindow:
19 browser->window()->GetNativeWindow()] toolbarController]; 20 browser->window()->GetNativeWindow()] toolbarController];
20 } 21 }
21 22
22 // Checks that the |bubble| is using the |expectedReferenceView|, and is in 23 // Checks that the |bubble| is using the |expectedReferenceView|, and is in
23 // approximately the correct position. 24 // approximately the correct position.
24 void CheckBubbleAndReferenceView(ToolbarActionsBarBubbleMac* bubble, 25 void CheckBubbleAndReferenceView(ToolbarActionsBarBubbleMac* bubble,
25 NSView* expectedReferenceView) { 26 NSView* expectedReferenceView) {
26 ASSERT_TRUE(bubble); 27 ASSERT_TRUE(bubble);
27 ASSERT_TRUE(expectedReferenceView); 28 ASSERT_TRUE(expectedReferenceView);
28 29
29 // Do a rough check that the bubble is in the right place. 30 // Do a rough check that the bubble is in the right place.
30 // A window's frame (like the bubble's) is already in screen coordinates. 31 // A window's frame (like the bubble's) is already in screen coordinates.
31 NSRect bubbleFrame = [[bubble window] frame]; 32 NSRect bubbleFrame = [[bubble window] frame];
32 33
33 // Unfortunately, it's more tedious to get the reference view's screen 34 // Unfortunately, it's more tedious to get the reference view's screen
34 // coordinates (since -[NSWindow convertRectToScreen is in OSX 10.7). 35 // coordinates (since -[NSWindow convertRectToScreen is in OSX 10.7).
35 NSRect referenceFrame = [expectedReferenceView bounds]; 36 NSRect referenceFrame = [expectedReferenceView bounds];
36 referenceFrame = 37 referenceFrame =
37 [expectedReferenceView convertRect:referenceFrame toView:nil]; 38 [expectedReferenceView convertRect:referenceFrame toView:nil];
38 NSWindow* window = [expectedReferenceView window]; 39 NSWindow* window = [expectedReferenceView window];
39 CGFloat refLowY = [expectedReferenceView isFlipped] ? 40 CGFloat refLowY = [expectedReferenceView isFlipped] ?
40 NSMaxY(referenceFrame) : NSMinY(referenceFrame); 41 NSMaxY(referenceFrame) : NSMinY(referenceFrame);
41 NSPoint refLowerLeft = NSMakePoint(NSMinX(referenceFrame), refLowY); 42 NSPoint refLowerLeft = NSMakePoint(NSMinX(referenceFrame), refLowY);
42 NSPoint refLowerLeftInScreen = [window convertBaseToScreen:refLowerLeft]; 43 NSPoint refLowerLeftInScreen =
44 ui::ConvertPointFromWindowToScreen(window, refLowerLeft);
43 NSPoint refLowerRight = NSMakePoint(NSMaxX(referenceFrame), refLowY); 45 NSPoint refLowerRight = NSMakePoint(NSMaxX(referenceFrame), refLowY);
44 NSPoint refLowerRightInScreen = [window convertBaseToScreen:refLowerRight]; 46 NSPoint refLowerRightInScreen =
47 ui::ConvertPointFromWindowToScreen(window, refLowerRight);
45 48
46 // The bubble should be below the reference view, but not too far below. 49 // The bubble should be below the reference view, but not too far below.
47 EXPECT_LE(NSMaxY(bubbleFrame), refLowerLeftInScreen.y); 50 EXPECT_LE(NSMaxY(bubbleFrame), refLowerLeftInScreen.y);
48 // "Too far below" is kind of ambiguous. The exact logic of where a bubble 51 // "Too far below" is kind of ambiguous. The exact logic of where a bubble
49 // is positioned with respect to its anchor view should be tested as part of 52 // is positioned with respect to its anchor view should be tested as part of
50 // the bubble logic, but we still want to make sure we didn't accidentally 53 // the bubble logic, but we still want to make sure we didn't accidentally
51 // place it somewhere crazy (which can happen if we draw it, and then 54 // place it somewhere crazy (which can happen if we draw it, and then
52 // animate or reposition the reference view). 55 // animate or reposition the reference view).
53 const int kFudgeFactor = 50; 56 const int kFudgeFactor = 50;
54 EXPECT_LE(NSMaxY(bubbleFrame), refLowerLeftInScreen.y + kFudgeFactor); 57 EXPECT_LE(NSMaxY(bubbleFrame), refLowerLeftInScreen.y + kFudgeFactor);
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after
142 145
143 IN_PROC_BROWSER_TEST_F(ExtensionMessageBubbleBrowserTestMac, 146 IN_PROC_BROWSER_TEST_F(ExtensionMessageBubbleBrowserTestMac,
144 ExtensionBubbleShowsOnStartup) { 147 ExtensionBubbleShowsOnStartup) {
145 TestBubbleShowsOnStartup(); 148 TestBubbleShowsOnStartup();
146 } 149 }
147 150
148 IN_PROC_BROWSER_TEST_F(ExtensionMessageBubbleBrowserTestMac, 151 IN_PROC_BROWSER_TEST_F(ExtensionMessageBubbleBrowserTestMac,
149 TestUninstallDangerousExtension) { 152 TestUninstallDangerousExtension) {
150 TestUninstallDangerousExtension(); 153 TestUninstallDangerousExtension();
151 } 154 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698