| OLD | NEW |
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "base/scoped_nsobject.h" | 5 #include "base/scoped_nsobject.h" |
| 6 #import "chrome/browser/cocoa/cocoa_test_helper.h" | 6 #import "chrome/browser/cocoa/cocoa_test_helper.h" |
| 7 #import "chrome/browser/cocoa/extensions/browser_actions_container_view.h" | 7 #import "chrome/browser/cocoa/extensions/browser_actions_container_view.h" |
| 8 #include "testing/gtest/include/gtest/gtest.h" | 8 #include "testing/gtest/include/gtest/gtest.h" |
| 9 #include "testing/platform_test.h" | 9 #include "testing/platform_test.h" |
| 10 | 10 |
| 11 namespace { | 11 namespace { |
| 12 | 12 |
| 13 const CGFloat kContainerHeight = 15.0; | 13 const CGFloat kContainerHeight = 15.0; |
| 14 const CGFloat kMinimumContainerWidth = 10.0; |
| 14 | 15 |
| 15 class BrowserActionsContainerViewTest : public CocoaTest { | 16 class BrowserActionsContainerViewTest : public CocoaTest { |
| 16 public: | 17 public: |
| 17 virtual void SetUp() { | 18 virtual void SetUp() { |
| 18 CocoaTest::SetUp(); | 19 CocoaTest::SetUp(); |
| 19 view_.reset([[BrowserActionsContainerView alloc] | 20 view_.reset([[BrowserActionsContainerView alloc] |
| 20 initWithFrame:NSMakeRect(0, 0, 0, kContainerHeight)]); | 21 initWithFrame:NSMakeRect(0, 0, 0, kContainerHeight)]); |
| 21 } | 22 } |
| 22 | 23 |
| 23 scoped_nsobject<BrowserActionsContainerView> view_; | 24 scoped_nsobject<BrowserActionsContainerView> view_; |
| 24 }; | 25 }; |
| 25 | 26 |
| 26 TEST_F(BrowserActionsContainerViewTest, BasicTests) { | 27 TEST_F(BrowserActionsContainerViewTest, BasicTests) { |
| 27 EXPECT_TRUE([view_ isResizable]); | 28 EXPECT_TRUE([view_ isResizable]); |
| 28 EXPECT_TRUE([view_ canDragLeft]); | 29 EXPECT_TRUE([view_ canDragLeft]); |
| 29 EXPECT_TRUE([view_ canDragRight]); | 30 EXPECT_TRUE([view_ canDragRight]); |
| 30 EXPECT_TRUE([view_ isHidden]); | 31 EXPECT_TRUE([view_ isHidden]); |
| 31 } | 32 } |
| 32 | 33 |
| 34 TEST_F(BrowserActionsContainerViewTest, SetWidthTests) { |
| 35 // Try setting below the minimum width (10 pixels). |
| 36 [view_ resizeToWidth:5.0 animate:NO]; |
| 37 EXPECT_EQ(kMinimumContainerWidth, NSWidth([view_ frame])) << "Frame width is " |
| 38 << "less than the minimum allowed."; |
| 39 // Since the frame expands to the left, the x-position delta value will be |
| 40 // negative. |
| 41 EXPECT_EQ(-kMinimumContainerWidth, [view_ resizeDeltaX]); |
| 42 |
| 43 [view_ resizeToWidth:35.0 animate:NO]; |
| 44 EXPECT_EQ(35.0, NSWidth([view_ frame])); |
| 45 EXPECT_EQ(-25.0, [view_ resizeDeltaX]); |
| 46 |
| 47 [view_ resizeToWidth:20.0 animate:NO]; |
| 48 EXPECT_EQ(20.0, NSWidth([view_ frame])); |
| 49 EXPECT_EQ(15.0, [view_ resizeDeltaX]); |
| 50 } |
| 51 |
| 33 } // namespace | 52 } // namespace |
| OLD | NEW |