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

Unified Diff: chrome/browser/cocoa/browser_window_controller_unittest.mm

Issue 391035: [Mac] Add support for growing or shrinking the window during animations.... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 11 years, 1 month 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 | « chrome/browser/cocoa/browser_window_controller.mm ('k') | chrome/browser/cocoa/toolbar_controller.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/cocoa/browser_window_controller_unittest.mm
===================================================================
--- chrome/browser/cocoa/browser_window_controller_unittest.mm (revision 32529)
+++ chrome/browser/cocoa/browser_window_controller_unittest.mm (working copy)
@@ -194,6 +194,63 @@
}
} // end namespace
+TEST_F(BrowserWindowControllerTest, TestAdjustWindowHeight) {
+ NSWindow* window = [controller_ window];
+ NSRect workarea = [[window screen] visibleFrame];
+
+ // Place the window well above the bottom of the screen and try to adjust its
+ // height.
+ NSRect initialFrame = NSMakeRect(workarea.origin.x, workarea.origin.y + 100,
+ 200, 200);
+ [window setFrame:initialFrame display:YES];
+ [controller_ adjustWindowHeightBy:40];
+ NSRect finalFrame = [window frame];
+ EXPECT_FALSE(NSEqualRects(finalFrame, initialFrame));
+ EXPECT_FLOAT_EQ(NSHeight(finalFrame), NSHeight(initialFrame) + 40);
+
+ // Place the window at the bottom of the screen and try again. Its height
+ // should still change, but it should not grow down below the work area.
+ initialFrame = NSMakeRect(workarea.origin.x, workarea.origin.y, 200, 200);
+ [window setFrame:initialFrame display:YES];
+ [controller_ adjustWindowHeightBy:40];
+ EXPECT_FALSE(NSEqualRects(finalFrame, initialFrame));
+ EXPECT_GE(NSMinY(finalFrame), NSMinY(initialFrame));
+ EXPECT_FLOAT_EQ(NSHeight(finalFrame), NSHeight(initialFrame) + 40);
+
+ // Move the window slightly offscreen and try again. The height should not
+ // change this time.
+ initialFrame = NSMakeRect(workarea.origin.x - 10, 0, 200, 200);
+ [window setFrame:initialFrame display:YES];
+ [controller_ adjustWindowHeightBy:40];
+ EXPECT_TRUE(NSEqualRects([window frame], initialFrame));
+
+ // Make the window the same size as the workarea. Resizing both larger and
+ // smaller should have no effect.
+ [window setFrame:workarea display:YES];
+ [controller_ adjustWindowHeightBy:40];
+ EXPECT_TRUE(NSEqualRects([window frame], workarea));
+ [controller_ adjustWindowHeightBy:-40];
+ EXPECT_TRUE(NSEqualRects([window frame], workarea));
+
+ // Make the window smaller than the workarea and place it near the bottom of
+ // the workarea. The window should grow down until it hits the bottom and
+ // then continue to grow up.
+ initialFrame = NSMakeRect(workarea.origin.x, workarea.origin.y + 5,
+ 200, 200);
+ [window setFrame:initialFrame display:YES];
+ [controller_ adjustWindowHeightBy:40];
+ finalFrame = [window frame];
+ EXPECT_EQ(NSMinY(workarea), NSMinY(finalFrame));
+ EXPECT_FLOAT_EQ(NSHeight(finalFrame), NSHeight(initialFrame) + 40);
+
+ // Inset the window slightly from the workarea. It should not grow to be
+ // larger than the workarea.
+ initialFrame = NSInsetRect(workarea, 0, 5);
+ [window setFrame:initialFrame display:YES];
+ [controller_ adjustWindowHeightBy:40];
+ EXPECT_EQ(NSHeight(workarea), NSHeight([window frame]));
+}
+
// Test to make sure resizing and relaying-out subviews works correctly.
TEST_F(BrowserWindowControllerTest, TestResizeViews) {
TabStripView* tabstrip = [controller_ tabStripView];
@@ -205,9 +262,7 @@
// We need to muck with the views a bit to put us in a consistent state before
// we start resizing. In particular, we need to move the tab strip to be
// immediately above the content area, since we layout views to be directly
- // under the tab strip. We also explicitly set the contentView's frame to be
- // 800x600.
- [contentView setFrame:NSMakeRect(0, 0, 800, 600)];
+ // under the tab strip.
NSRect tabstripFrame = [tabstrip frame];
tabstripFrame.origin.y = NSMaxY([contentView frame]);
[tabstrip setFrame:tabstripFrame];
@@ -215,7 +270,9 @@
// The download shelf is created lazily. Force-create it and set its initial
// height to 0.
NSView* download = [[controller_ downloadShelf] view];
- [controller_ resizeView:download newHeight:0];
+ NSRect downloadFrame = [download frame];
+ downloadFrame.size.height = 0;
+ [download setFrame:downloadFrame];
// Force a layout and check each view's frame.
[controller_ layoutSubviews];
@@ -259,9 +316,7 @@
// We need to muck with the views a bit to put us in a consistent state before
// we start resizing. In particular, we need to move the tab strip to be
// immediately above the content area, since we layout views to be directly
- // under the tab strip. We also explicitly set the contentView's frame to be
- // 800x600.
- [contentView setFrame:NSMakeRect(0, 0, 800, 600)];
+ // under the tab strip.
NSRect tabstripFrame = [tabstrip frame];
tabstripFrame.origin.y = NSMaxY([contentView frame]);
[tabstrip setFrame:tabstripFrame];
@@ -269,7 +324,9 @@
// The download shelf is created lazily. Force-create it and set its initial
// height to 0.
NSView* download = [[controller_ downloadShelf] view];
- [controller_ resizeView:download newHeight:0];
+ NSRect downloadFrame = [download frame];
+ downloadFrame.size.height = 0;
+ [download setFrame:downloadFrame];
// Force a layout and check each view's frame.
[controller_ layoutSubviews];
« no previous file with comments | « chrome/browser/cocoa/browser_window_controller.mm ('k') | chrome/browser/cocoa/toolbar_controller.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698