diff options
author | pinkerton@chromium.org <pinkerton@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-09-02 18:07:15 +0000 |
---|---|---|
committer | pinkerton@chromium.org <pinkerton@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-09-02 18:07:15 +0000 |
commit | 1324923828e8be46ef8b532e5c8955d3f9a9782e (patch) | |
tree | f60443978dd64036f72ba55eaeb8950ceecc3caa /chrome/browser/cocoa | |
parent | 294ea5aa11b1965820fc26877374200da6b2013a (diff) | |
download | chromium_src-1324923828e8be46ef8b532e5c8955d3f9a9782e.zip chromium_src-1324923828e8be46ef8b532e5c8955d3f9a9782e.tar.gz chromium_src-1324923828e8be46ef8b532e5c8955d3f9a9782e.tar.bz2 |
Don't allow the home/page/options buttons to be toggled when we're only showing the url bar, with accompanying unit test.
BUG=17825
TEST=make sure you can still show these optional elements in normal windows.
Review URL: http://codereview.chromium.org/188010
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@25197 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/cocoa')
-rw-r--r-- | chrome/browser/cocoa/toolbar_controller.mm | 6 | ||||
-rw-r--r-- | chrome/browser/cocoa/toolbar_controller_unittest.mm | 24 |
2 files changed, 30 insertions, 0 deletions
diff --git a/chrome/browser/cocoa/toolbar_controller.mm b/chrome/browser/cocoa/toolbar_controller.mm index fdbbd8e..f3c7b13 100644 --- a/chrome/browser/cocoa/toolbar_controller.mm +++ b/chrome/browser/cocoa/toolbar_controller.mm @@ -368,6 +368,9 @@ class PrefObserverBridge : public NotificationObserver { // Show or hide the home button based on the pref. - (void)showOptionalHomeButton { + // Ignore this message if only showing the URL bar. + if (!hasToolbar_) + return; BOOL hide = showHomeButton_.GetValue() ? NO : YES; if (hide == [homeButton_ isHidden]) return; // Nothing to do, view state matches pref state. @@ -387,6 +390,9 @@ class PrefObserverBridge : public NotificationObserver { // Show or hide the page and wrench buttons based on the pref. - (void)showOptionalPageWrenchButtons { + // Ignore this message if only showing the URL bar. + if (!hasToolbar_) + return; DCHECK([pageButton_ isHidden] == [wrenchButton_ isHidden]); BOOL hide = showPageOptionButtons_.GetValue() ? NO : YES; if (hide == [pageButton_ isHidden]) diff --git a/chrome/browser/cocoa/toolbar_controller_unittest.mm b/chrome/browser/cocoa/toolbar_controller_unittest.mm index 678bfd5..4bc085c 100644 --- a/chrome/browser/cocoa/toolbar_controller_unittest.mm +++ b/chrome/browser/cocoa/toolbar_controller_unittest.mm @@ -196,6 +196,30 @@ TEST_F(ToolbarControllerTest, TogglePageWrench) { EXPECT_NE(NSWidth(originalLocationBarFrame), NSWidth([locationBar frame])); } +// Ensure that we don't toggle the buttons when we have a strip marked as not +// having the full toolbar. Also ensure that the location bar doesn't change +// size. +TEST_F(ToolbarControllerTest, DontToggleWhenNoToolbar) { + [bar_ setHasToolbar:NO]; + NSView* homeButton = [[bar_ toolbarViews] objectAtIndex:kHomeIndex]; + NSView* pageButton = [[bar_ toolbarViews] objectAtIndex:kPageIndex]; + NSView* wrenchButton = [[bar_ toolbarViews] objectAtIndex:kWrenchIndex]; + NSView* locationBar = [[bar_ toolbarViews] objectAtIndex:kLocationIndex]; + NSRect locationBarFrame = [locationBar frame]; + EXPECT_EQ([homeButton isHidden], YES); + EXPECT_EQ([pageButton isHidden], YES); + EXPECT_EQ([wrenchButton isHidden], YES); + [bar_ showOptionalHomeButton]; + EXPECT_EQ([homeButton isHidden], YES); + NSRect newLocationBarFrame = [locationBar frame]; + EXPECT_TRUE(NSEqualRects(locationBarFrame, newLocationBarFrame)); + [bar_ showOptionalPageWrenchButtons]; + EXPECT_EQ([pageButton isHidden], YES); + EXPECT_EQ([wrenchButton isHidden], YES); + newLocationBarFrame = [locationBar frame]; + EXPECT_TRUE(NSEqualRects(locationBarFrame, newLocationBarFrame)); +} + // Make sure, by default, the bookmark bar is the full width of the // toolbar. TEST_F(ToolbarControllerTest, BookmarkBarIsFullWidth) { |