summaryrefslogtreecommitdiffstats
path: root/chrome/browser/cocoa/toolbar_controller_unittest.mm
diff options
context:
space:
mode:
authorrohitrao@chromium.org <rohitrao@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-08-07 04:49:14 +0000
committerrohitrao@chromium.org <rohitrao@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-08-07 04:49:14 +0000
commit7b0ec59003697f626184af266d670b014c5715d5 (patch)
tree1c4864c9268e1cec9c7c83d328db3bb323fb92c9 /chrome/browser/cocoa/toolbar_controller_unittest.mm
parentc1d10a389f07e7cf1274cb4c053e5cee0bda095a (diff)
downloadchromium_src-7b0ec59003697f626184af266d670b014c5715d5.zip
chromium_src-7b0ec59003697f626184af266d670b014c5715d5.tar.gz
chromium_src-7b0ec59003697f626184af266d670b014c5715d5.tar.bz2
Reverts the revert of 22517.
Rewrites the Mac view resizing logic to have the BrowserWindowController directly resize and relayout its children views. Now when a view needs to be resized, it asks its resize delegate (typically its controller's parent) to perform the resize. BUG=http://crbug.com/17619 TEST=Make sure that views are laid out correctly, even when they change size. Open and close the bookmark bar. Trigger an infobar and then close it. Trigger the download shelf and then close it. Trigger a download shelf with the infobar open, or with the bookmark bar open. Switch to and from fullscreen with various bars open. Resize the browser window with various bars open. Start the browser with and without the bookmark bar open. Try all of the above in a popup window. Review URL: http://codereview.chromium.org/165014 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@22721 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/cocoa/toolbar_controller_unittest.mm')
-rw-r--r--chrome/browser/cocoa/toolbar_controller_unittest.mm34
1 files changed, 32 insertions, 2 deletions
diff --git a/chrome/browser/cocoa/toolbar_controller_unittest.mm b/chrome/browser/cocoa/toolbar_controller_unittest.mm
index 9690c5b..a82212b 100644
--- a/chrome/browser/cocoa/toolbar_controller_unittest.mm
+++ b/chrome/browser/cocoa/toolbar_controller_unittest.mm
@@ -9,6 +9,7 @@
#include "chrome/browser/cocoa/browser_test_helper.h"
#import "chrome/browser/cocoa/cocoa_test_helper.h"
#import "chrome/browser/cocoa/toolbar_controller.h"
+#import "chrome/browser/cocoa/view_resizer_pong.h"
#include "chrome/common/pref_names.h"
#include "chrome/common/pref_service.h"
#include "testing/gtest/include/gtest/gtest.h"
@@ -32,12 +33,12 @@ class ToolbarControllerTest : public testing::Test {
// ensure they get picked up correct on initialization
updater->UpdateCommandEnabled(IDC_BACK, false);
updater->UpdateCommandEnabled(IDC_FORWARD, false);
+ resizeDelegate_.reset([[ViewResizerPong alloc] init]);
bar_.reset(
[[ToolbarController alloc] initWithModel:browser->toolbar_model()
commands:browser->command_updater()
profile:helper_.profile()
- webContentView:nil
- infoBarsView:nil
+ resizeDelegate:resizeDelegate_.get()
bookmarkDelegate:nil]);
EXPECT_TRUE([bar_ view]);
NSView* parent = [cocoa_helper_.window() contentView];
@@ -61,6 +62,7 @@ class ToolbarControllerTest : public testing::Test {
CocoaTestHelper cocoa_helper_; // Inits Cocoa, creates window, etc...
BrowserTestHelper helper_;
+ scoped_nsobject<ViewResizerPong> resizeDelegate_;
scoped_nsobject<ToolbarController> bar_;
};
@@ -192,4 +194,32 @@ TEST_F(ToolbarControllerTest, TogglePageWrench) {
EXPECT_NE(NSWidth(originalLocationBarFrame), NSWidth([locationBar frame]));
}
+TEST_F(ToolbarControllerTest, BookmarkBarResizes) {
+ NSView* bookmarkBarView = [[bar_ bookmarkBarController] view];
+ ASSERT_EQ(0, NSHeight([bookmarkBarView frame]));
+ [resizeDelegate_ setHeight:-1];
+
+ // Resize the bookmarkbar to 30px. The toolbar should ask the delegate to
+ // resize to 64px.
+ [bar_ resizeView:bookmarkBarView newHeight:30];
+ EXPECT_EQ(64, [resizeDelegate_ height]);
+ EXPECT_EQ(30, NSHeight([bookmarkBarView frame]));
+
+ // Resize the bookmarkbar back to 0px. Toolbar should be at 39px.
+ [bar_ resizeView:bookmarkBarView newHeight:0];
+ EXPECT_EQ(39, [resizeDelegate_ height]);
+ EXPECT_EQ(0, NSHeight([bookmarkBarView frame]));
+
+ // Resize the bookmarkbar to 5px. Toolbar should stay at 39px.
+ [resizeDelegate_ setHeight:-1];
+ [bar_ resizeView:bookmarkBarView newHeight:5];
+ EXPECT_EQ(39, [resizeDelegate_ height]);
+ EXPECT_EQ(5, NSHeight([bookmarkBarView frame]));
+
+ // Resize the bookmarkbar to 6px. Toolbar should grow to 40px.
+ [bar_ resizeView:bookmarkBarView newHeight:6];
+ EXPECT_EQ(40, [resizeDelegate_ height]);
+ EXPECT_EQ(6, NSHeight([bookmarkBarView frame]));
+}
+
} // namespace