Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(211)

Side by Side Diff: chrome/browser/ui/cocoa/extensions/browser_actions_container_view_unittest.mm

Issue 1009613002: [Toolbar UI Mac] Fix omnibox minimum width (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Avi's Created 5 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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
23 CGFloat GetMaxAllowedWidth() override { return kMaxAllowedWidthForTest; }
24
25 private:
26 DISALLOW_COPY_AND_ASSIGN(BrowserActionsContainerTestDelegate);
27 };
15 28
16 class BrowserActionsContainerViewTest : public CocoaTest { 29 class BrowserActionsContainerViewTest : public CocoaTest {
17 public: 30 public:
18 void SetUp() override { 31 void SetUp() override {
19 CocoaTest::SetUp(); 32 CocoaTest::SetUp();
20 view_.reset([[BrowserActionsContainerView alloc] 33 view_.reset([[BrowserActionsContainerView alloc]
21 initWithFrame:NSMakeRect(0, 0, 0, kContainerHeight)]); 34 initWithFrame:NSMakeRect(0, 0, 0, kContainerHeight)]);
22 } 35 }
23 36
24 base::scoped_nsobject<BrowserActionsContainerView> view_; 37 base::scoped_nsobject<BrowserActionsContainerView> view_;
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
57 // The container should be able to be resized while animating (simply taking 70 // The container should be able to be resized while animating (simply taking
58 // the newest target width). 71 // the newest target width).
59 [view_ resizeToWidth:30.0 animate:YES]; 72 [view_ resizeToWidth:30.0 animate:YES];
60 EXPECT_EQ(30.0, NSWidth([view_ animationEndFrame])); 73 EXPECT_EQ(30.0, NSWidth([view_ animationEndFrame]));
61 74
62 // Test with no animation again. The animationEndFrame should also reflect 75 // Test with no animation again. The animationEndFrame should also reflect
63 // the current frame, if no animation is pending. 76 // the current frame, if no animation is pending.
64 [view_ resizeToWidth:35.0 animate:NO]; 77 [view_ resizeToWidth:35.0 animate:NO];
65 EXPECT_EQ(35.0, NSWidth([view_ frame])); 78 EXPECT_EQ(35.0, NSWidth([view_ frame]));
66 EXPECT_EQ(35.0, NSWidth([view_ animationEndFrame])); 79 EXPECT_EQ(35.0, NSWidth([view_ animationEndFrame]));
80
81 BrowserActionsContainerTestDelegate delegate;
82 [view_ setDelegate:&delegate];
83 [view_ resizeToWidth:kMaxAllowedWidthForTest + 10.0 animate:NO];
84 EXPECT_EQ(kMaxAllowedWidthForTest, NSWidth([view_ frame]));
85 [view_ setDelegate:nil];
67 } 86 }
68 87
69 } // namespace 88 } // namespace
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698