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

Unified Diff: chrome/browser/ui/cocoa/browser_window_controller_browsertest.mm

Issue 665933005: mac: Fix bug where finder window extends past bottom of screen. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase against top of tree. Comments from rsesek. Created 6 years, 2 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | chrome/browser/ui/cocoa/browser_window_controller_private.mm » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/ui/cocoa/browser_window_controller_browsertest.mm
diff --git a/chrome/browser/ui/cocoa/browser_window_controller_browsertest.mm b/chrome/browser/ui/cocoa/browser_window_controller_browsertest.mm
index 7c534494047dc53295afc76dc31580810d06bdab..48525170d52ae7a5395d38068567b7932fa91304 100644
--- a/chrome/browser/ui/cocoa/browser_window_controller_browsertest.mm
+++ b/chrome/browser/ui/cocoa/browser_window_controller_browsertest.mm
@@ -40,11 +40,21 @@
#include "content/public/browser/web_contents.h"
#include "content/public/test/test_utils.h"
#import "testing/gtest_mac.h"
+#import "third_party/ocmock/OCMock/OCMock.h"
#import "ui/base/cocoa/nsview_additions.h"
#include "ui/gfx/animation/slide_animation.h"
namespace {
+// Creates a mock of an NSWindow that has the given |frame|.
+id MockWindowWithFrame(NSRect frame) {
+ id window = [OCMockObject mockForClass:[NSWindow class]];
+ NSValue* window_frame =
+ [NSValue valueWithBytes:&frame objCType:@encode(NSRect)];
+ [[[window stub] andReturnValue:window_frame] frame];
+ return window;
+}
+
void CreateProfileCallback(const base::Closure& quit_closure,
Profile* profile,
Profile::CreateStatus status) {
@@ -482,6 +492,7 @@ IN_PROC_BROWSER_TEST_F(BrowserWindowControllerTest, SheetPosition) {
EXPECT_FALSE([controller() isBookmarkBarVisible]);
NSRect defaultAlertFrame = NSMakeRect(0, 0, 300, 200);
+ id sheet = MockWindowWithFrame(defaultAlertFrame);
NSWindow* window = browser()->window()->GetNativeWindow();
NSRect alertFrame = [controller() window:window
willPositionSheet:nil
@@ -493,11 +504,24 @@ IN_PROC_BROWSER_TEST_F(BrowserWindowControllerTest, SheetPosition) {
chrome::ToggleBookmarkBarWhenVisible(browser()->profile());
EXPECT_TRUE([controller() isBookmarkBarVisible]);
alertFrame = [controller() window:window
- willPositionSheet:nil
+ willPositionSheet:sheet
usingRect:defaultAlertFrame];
NSRect bookmarkBarFrame = [[[controller() bookmarkBarController] view] frame];
EXPECT_EQ(NSMinY(alertFrame), NSMinY(bookmarkBarFrame));
+ // If the sheet is too large, it should be positioned at the top of the
+ // window.
+ defaultAlertFrame = NSMakeRect(0, 0, 300, 2000);
+ sheet = MockWindowWithFrame(defaultAlertFrame);
+ alertFrame = [controller() window:window
+ willPositionSheet:sheet
+ usingRect:defaultAlertFrame];
+ EXPECT_EQ(NSMinY(alertFrame), NSHeight([window frame]));
+
+ // Reset the sheet's size.
+ defaultAlertFrame = NSMakeRect(0, 0, 300, 200);
+ sheet = MockWindowWithFrame(defaultAlertFrame);
+
// Make sure the profile does not have the bookmark visible so that
// we'll create the shortcut window without the bookmark bar.
chrome::ToggleBookmarkBarWhenVisible(browser()->profile());
@@ -518,7 +542,7 @@ IN_PROC_BROWSER_TEST_F(BrowserWindowControllerTest, SheetPosition) {
// Open sheet in an application window.
[popupController showWindow:nil];
alertFrame = [popupController window:popupWindow
- willPositionSheet:nil
+ willPositionSheet:sheet
usingRect:defaultAlertFrame];
EXPECT_EQ(NSMinY(alertFrame),
NSHeight([[popupWindow contentView] frame]) -
« no previous file with comments | « no previous file | chrome/browser/ui/cocoa/browser_window_controller_private.mm » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698