summaryrefslogtreecommitdiffstats
path: root/chrome/browser/cocoa/toolbar_controller_unittest.mm
diff options
context:
space:
mode:
authorpinkerton@chromium.org <pinkerton@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-07-07 18:43:09 +0000
committerpinkerton@chromium.org <pinkerton@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-07-07 18:43:09 +0000
commit93a2c7241cddc33af51cdc3daea03e414f544ec8 (patch)
tree1864bba1f4c906e7d67ac378814455ec24d8a992 /chrome/browser/cocoa/toolbar_controller_unittest.mm
parent2e8f3dd5dbec1c494778713c47a42f6589ecbc86 (diff)
downloadchromium_src-93a2c7241cddc33af51cdc3daea03e414f544ec8.zip
chromium_src-93a2c7241cddc33af51cdc3daea03e414f544ec8.tar.gz
chromium_src-93a2c7241cddc33af51cdc3daea03e414f544ec8.tar.bz2
Hook up the prefs for the optional home buttons and page/wrench buttons. Move default registration of this pref out of platform code and into shared code to avoid having to do it in at least 3 places. Fix gradient buttons to not draw their borders unless asked.
BUG=13151 TEST=showing/hiding home button and page/wrench buttons should work. Menus for page/wrench should work except for a few straggler items that aren't yet implemented even in the main menubar. Review URL: http://codereview.chromium.org/155151 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@20052 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/cocoa/toolbar_controller_unittest.mm')
-rw-r--r--chrome/browser/cocoa/toolbar_controller_unittest.mm53
1 files changed, 50 insertions, 3 deletions
diff --git a/chrome/browser/cocoa/toolbar_controller_unittest.mm b/chrome/browser/cocoa/toolbar_controller_unittest.mm
index 2afc327..6562cce 100644
--- a/chrome/browser/cocoa/toolbar_controller_unittest.mm
+++ b/chrome/browser/cocoa/toolbar_controller_unittest.mm
@@ -9,6 +9,8 @@
#include "chrome/browser/cocoa/browser_test_helper.h"
#import "chrome/browser/cocoa/cocoa_test_helper.h"
#import "chrome/browser/cocoa/toolbar_controller.h"
+#include "chrome/common/pref_names.h"
+#include "chrome/common/pref_service.h"
#include "testing/gtest/include/gtest/gtest.h"
namespace {
@@ -19,8 +21,8 @@ class ToolbarControllerTest : public testing::Test {
// Indexes that match the ordering returned by the private ToolbarController
// |-toolbarViews| method.
enum {
- kBackIndex, kForwardIndex, kReloadIndex, kStarIndex, kGoIndex,
- kLocationIndex,
+ kBackIndex, kForwardIndex, kReloadIndex, kHomeIndex, kStarIndex, kGoIndex,
+ kPageIndex, kWrenchIndex, kLocationIndex,
};
ToolbarControllerTest() {
@@ -48,7 +50,8 @@ class ToolbarControllerTest : public testing::Test {
[[views objectAtIndex:kForwardIndex] isEnabled] ? true : false);
EXPECT_EQ(updater->IsCommandEnabled(IDC_RELOAD),
[[views objectAtIndex:kReloadIndex] isEnabled] ? true : false);
- // TODO(pinkerton): Add IDC_HOME when we get a view for it
+ EXPECT_EQ(updater->IsCommandEnabled(IDC_HOME),
+ [[views objectAtIndex:kHomeIndex] isEnabled] ? true : false);
EXPECT_EQ(updater->IsCommandEnabled(IDC_STAR),
[[views objectAtIndex:kStarIndex] isEnabled] ? true : false);
}
@@ -111,4 +114,48 @@ TEST_F(ToolbarControllerTest, LoadingState) {
EXPECT_EQ([go tag], IDC_GO);
}
+// Check that toggling the state of the home button changes the visible
+// state of the home button and moves the other buttons accordingly.
+TEST_F(ToolbarControllerTest, ToggleHome) {
+ PrefService* prefs = helper_.profile()->GetPrefs();
+ bool showHome = prefs->GetBoolean(prefs::kShowHomeButton);
+ NSView* homeButton = [[bar_ toolbarViews] objectAtIndex:kHomeIndex];
+ EXPECT_EQ(showHome, ![homeButton isHidden]);
+
+ NSView* starButton = [[bar_ toolbarViews] objectAtIndex:kStarIndex];
+ NSView* locationBar = [[bar_ toolbarViews] objectAtIndex:kLocationIndex];
+ NSRect originalStarFrame = [starButton frame];
+ NSRect originalLocationBarFrame = [locationBar frame];
+
+ // Toggle the pref and make sure the button changed state and the other
+ // views moved.
+ prefs->SetBoolean(prefs::kShowHomeButton, !showHome);
+ EXPECT_EQ(showHome, [homeButton isHidden]);
+ EXPECT_NE(NSMinX(originalStarFrame), NSMinX([starButton frame]));
+ EXPECT_NE(NSMinX(originalLocationBarFrame), NSMinX([locationBar frame]));
+ EXPECT_NE(NSWidth(originalLocationBarFrame), NSWidth([locationBar frame]));
+}
+
+TEST_F(ToolbarControllerTest, TogglePageWrench) {
+ PrefService* prefs = helper_.profile()->GetPrefs();
+ bool showButtons = prefs->GetBoolean(prefs::kShowPageOptionsButtons);
+ NSView* pageButton = [[bar_ toolbarViews] objectAtIndex:kPageIndex];
+ NSView* wrenchButton = [[bar_ toolbarViews] objectAtIndex:kWrenchIndex];
+ EXPECT_EQ(showButtons, ![pageButton isHidden]);
+ EXPECT_EQ(showButtons, ![wrenchButton isHidden]);
+
+ NSView* goButton = [[bar_ toolbarViews] objectAtIndex:kGoIndex];
+ NSView* locationBar = [[bar_ toolbarViews] objectAtIndex:kLocationIndex];
+ NSRect originalGoFrame = [goButton frame];
+ NSRect originalLocationBarFrame = [locationBar frame];
+
+ // Toggle the pref and make sure the buttons changed state and the other
+ // views moved (or in the case of the location bar, it changed width).
+ prefs->SetBoolean(prefs::kShowPageOptionsButtons, !showButtons);
+ EXPECT_EQ(showButtons, [pageButton isHidden]);
+ EXPECT_EQ(showButtons, [wrenchButton isHidden]);
+ EXPECT_NE(NSMinX(originalGoFrame), NSMinX([goButton frame]));
+ EXPECT_NE(NSWidth(originalLocationBarFrame), NSWidth([locationBar frame]));
+}
+
} // namespace