diff options
author | andybons@chromium.org <andybons@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-06-02 16:23:34 +0000 |
---|---|---|
committer | andybons@chromium.org <andybons@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-06-02 16:23:34 +0000 |
commit | d6ae0705254b8faeb1e00d3a42d3e6d3c09461a3 (patch) | |
tree | 13ca927ffad7429118ea9762795cd653160286a4 /chrome/browser/cocoa/extensions | |
parent | d0ac5afafd817a587008e2d96607568e5ebb3272 (diff) | |
download | chromium_src-d6ae0705254b8faeb1e00d3a42d3e6d3c09461a3.zip chromium_src-d6ae0705254b8faeb1e00d3a42d3e6d3c09461a3.tar.gz chromium_src-d6ae0705254b8faeb1e00d3a42d3e6d3c09461a3.tar.bz2 |
[Mac] Updates the unit test with some minor tweaks to the Browser Actions container view.
TEST=BrowserActionsContainerViewTest
BUG=none
Review URL: http://codereview.chromium.org/2426002
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@48727 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/cocoa/extensions')
3 files changed, 23 insertions, 6 deletions
diff --git a/chrome/browser/cocoa/extensions/browser_actions_container_view.h b/chrome/browser/cocoa/extensions/browser_actions_container_view.h index 32c6139..d91a185 100644 --- a/chrome/browser/cocoa/extensions/browser_actions_container_view.h +++ b/chrome/browser/cocoa/extensions/browser_actions_container_view.h @@ -43,9 +43,9 @@ extern const NSString* kBrowserActionGrippyDragFinishedNotification; // Whether the container is currently being resized by the user. BOOL userIsResizing_; - // Whether the user can resize this at all. Resizing is disabled in incognito + // Whether the user can resize this at all. Resizing is disabled in incognito // mode since any changes done in incognito mode are not saved anyway, and - // also to avoid a crash (http://crbug.com/42848). + // also to avoid a crash. http://crbug.com/42848 BOOL resizable_; // Whether the user is allowed to drag the grippy to the left. NO if all diff --git a/chrome/browser/cocoa/extensions/browser_actions_container_view.mm b/chrome/browser/cocoa/extensions/browser_actions_container_view.mm index 2bf6ea2..e2576f1 100644 --- a/chrome/browser/cocoa/extensions/browser_actions_container_view.mm +++ b/chrome/browser/cocoa/extensions/browser_actions_container_view.mm @@ -92,7 +92,8 @@ const CGFloat kUpperPadding = 9.0; [borderGradient drawInRect:borderRect angle:90.0]; } - [self drawGrippy]; + if (resizable_) + [self drawGrippy]; } - (void)resetCursorRects { @@ -215,9 +216,6 @@ const CGFloat kUpperPadding = 9.0; } - (void)drawGrippy { - if (!resizable_) - return; - NSRect grippyRect = NSMakeRect(0.0, kLowerPadding + kGrippyLowerPadding, 1.0, [self bounds].size.height - kUpperPadding - kGrippyUpperPadding); [[NSColor colorWithCalibratedWhite:0.7 alpha:0.5] set]; diff --git a/chrome/browser/cocoa/extensions/browser_actions_container_view_unittest.mm b/chrome/browser/cocoa/extensions/browser_actions_container_view_unittest.mm index f771ccd..ad120d7 100644 --- a/chrome/browser/cocoa/extensions/browser_actions_container_view_unittest.mm +++ b/chrome/browser/cocoa/extensions/browser_actions_container_view_unittest.mm @@ -11,6 +11,7 @@ namespace { const CGFloat kContainerHeight = 15.0; +const CGFloat kMinimumContainerWidth = 10.0; class BrowserActionsContainerViewTest : public CocoaTest { public: @@ -30,4 +31,22 @@ TEST_F(BrowserActionsContainerViewTest, BasicTests) { EXPECT_TRUE([view_ isHidden]); } +TEST_F(BrowserActionsContainerViewTest, SetWidthTests) { + // Try setting below the minimum width (10 pixels). + [view_ resizeToWidth:5.0 animate:NO]; + EXPECT_EQ(kMinimumContainerWidth, NSWidth([view_ frame])) << "Frame width is " + << "less than the minimum allowed."; + // Since the frame expands to the left, the x-position delta value will be + // negative. + EXPECT_EQ(-kMinimumContainerWidth, [view_ resizeDeltaX]); + + [view_ resizeToWidth:35.0 animate:NO]; + EXPECT_EQ(35.0, NSWidth([view_ frame])); + EXPECT_EQ(-25.0, [view_ resizeDeltaX]); + + [view_ resizeToWidth:20.0 animate:NO]; + EXPECT_EQ(20.0, NSWidth([view_ frame])); + EXPECT_EQ(15.0, [view_ resizeDeltaX]); +} + } // namespace |