OLD | NEW |
---|---|
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/mac/scoped_nsobject.h" | 5 #include "base/mac/scoped_nsobject.h" |
6 #import "chrome/browser/ui/cocoa/cocoa_test_helper.h" | 6 #import "chrome/browser/ui/cocoa/cocoa_test_helper.h" |
7 #import "chrome/browser/ui/cocoa/extensions/browser_actions_container_view.h" | 7 #import "chrome/browser/ui/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 = 3.0; | 14 const CGFloat kMinimumContainerWidth = 3.0; |
15 const CGFloat kMaxAllowedWidthForTest = 50.0; | |
16 | |
17 class BrowserActionsContainerTestDelegate | |
18 : public BrowserActionsContainerViewSizeDelegate { | |
19 public: | |
20 BrowserActionsContainerTestDelegate() {} | |
21 ~BrowserActionsContainerTestDelegate() override {} | |
22 CGFloat GetMaxAllowedWidth() override { return kMaxAllowedWidthForTest; } | |
Avi (use Gerrit)
2015/03/13 23:26:03
blank line before
Devlin
2015/03/14 00:03:14
Done.
| |
23 | |
24 private: | |
25 DISALLOW_COPY_AND_ASSIGN(BrowserActionsContainerTestDelegate); | |
26 }; | |
15 | 27 |
16 class BrowserActionsContainerViewTest : public CocoaTest { | 28 class BrowserActionsContainerViewTest : public CocoaTest { |
17 public: | 29 public: |
18 void SetUp() override { | 30 void SetUp() override { |
19 CocoaTest::SetUp(); | 31 CocoaTest::SetUp(); |
20 view_.reset([[BrowserActionsContainerView alloc] | 32 view_.reset([[BrowserActionsContainerView alloc] |
21 initWithFrame:NSMakeRect(0, 0, 0, kContainerHeight)]); | 33 initWithFrame:NSMakeRect(0, 0, 0, kContainerHeight)]); |
22 } | 34 } |
23 | 35 |
24 base::scoped_nsobject<BrowserActionsContainerView> view_; | 36 base::scoped_nsobject<BrowserActionsContainerView> view_; |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
57 // The container should be able to be resized while animating (simply taking | 69 // The container should be able to be resized while animating (simply taking |
58 // the newest target width). | 70 // the newest target width). |
59 [view_ resizeToWidth:30.0 animate:YES]; | 71 [view_ resizeToWidth:30.0 animate:YES]; |
60 EXPECT_EQ(30.0, NSWidth([view_ animationEndFrame])); | 72 EXPECT_EQ(30.0, NSWidth([view_ animationEndFrame])); |
61 | 73 |
62 // Test with no animation again. The animationEndFrame should also reflect | 74 // Test with no animation again. The animationEndFrame should also reflect |
63 // the current frame, if no animation is pending. | 75 // the current frame, if no animation is pending. |
64 [view_ resizeToWidth:35.0 animate:NO]; | 76 [view_ resizeToWidth:35.0 animate:NO]; |
65 EXPECT_EQ(35.0, NSWidth([view_ frame])); | 77 EXPECT_EQ(35.0, NSWidth([view_ frame])); |
66 EXPECT_EQ(35.0, NSWidth([view_ animationEndFrame])); | 78 EXPECT_EQ(35.0, NSWidth([view_ animationEndFrame])); |
79 | |
80 BrowserActionsContainerTestDelegate delegate; | |
81 [view_ setDelegate:&delegate]; | |
82 [view_ resizeToWidth:kMaxAllowedWidthForTest + 10.0 animate:NO]; | |
83 EXPECT_EQ(kMaxAllowedWidthForTest, NSWidth([view_ frame])); | |
84 [view_ setDelegate:nil]; | |
67 } | 85 } |
68 | 86 |
69 } // namespace | 87 } // namespace |
OLD | NEW |