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

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

Issue 1061623002: [Toolbar Mac UI] Simplify and correct omnibox pinning (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 8 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
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
42 EXPECT_TRUE([view_ canDragLeft]); 42 EXPECT_TRUE([view_ canDragLeft]);
43 EXPECT_TRUE([view_ canDragRight]); 43 EXPECT_TRUE([view_ canDragRight]);
44 EXPECT_TRUE([view_ isHidden]); 44 EXPECT_TRUE([view_ isHidden]);
45 } 45 }
46 46
47 TEST_F(BrowserActionsContainerViewTest, SetWidthTests) { 47 TEST_F(BrowserActionsContainerViewTest, SetWidthTests) {
48 // Try setting below the minimum width (10 pixels). 48 // Try setting below the minimum width (10 pixels).
49 [view_ resizeToWidth:kMinimumContainerWidth - 1 animate:NO]; 49 [view_ resizeToWidth:kMinimumContainerWidth - 1 animate:NO];
50 EXPECT_EQ(kMinimumContainerWidth, NSWidth([view_ frame])) << "Frame width is " 50 EXPECT_EQ(kMinimumContainerWidth, NSWidth([view_ frame])) << "Frame width is "
51 << "less than the minimum allowed."; 51 << "less than the minimum allowed.";
52 // Since the frame expands to the left, the x-position delta value will be
53 // negative.
54 EXPECT_EQ(-kMinimumContainerWidth, [view_ resizeDeltaX]);
55 52
56 [view_ resizeToWidth:35.0 animate:NO]; 53 [view_ resizeToWidth:35.0 animate:NO];
57 EXPECT_EQ(35.0, NSWidth([view_ frame])); 54 EXPECT_EQ(35.0, NSWidth([view_ frame]));
58 EXPECT_EQ(kMinimumContainerWidth - 35.0, [view_ resizeDeltaX]);
59 55
60 [view_ resizeToWidth:20.0 animate:NO]; 56 [view_ resizeToWidth:20.0 animate:NO];
61 EXPECT_EQ(20.0, NSWidth([view_ frame])); 57 EXPECT_EQ(20.0, NSWidth([view_ frame]));
62 EXPECT_EQ(15.0, [view_ resizeDeltaX]);
63 58
64 // Resize the view with animation. It shouldn't immediately take the new 59 // Resize the view with animation. It shouldn't immediately take the new
65 // value, but the animationEndFrame should reflect the pending change. 60 // value, but the animationEndFrame should reflect the pending change.
66 [view_ resizeToWidth:40.0 animate:YES]; 61 [view_ resizeToWidth:40.0 animate:YES];
67 EXPECT_LE(NSWidth([view_ frame]), 40.0); 62 EXPECT_LE(NSWidth([view_ frame]), 40.0);
68 EXPECT_EQ(40.0, NSWidth([view_ animationEndFrame])); 63 EXPECT_EQ(40.0, NSWidth([view_ animationEndFrame]));
69 64
70 // The container should be able to be resized while animating (simply taking 65 // The container should be able to be resized while animating (simply taking
71 // the newest target width). 66 // the newest target width).
72 [view_ resizeToWidth:30.0 animate:YES]; 67 [view_ resizeToWidth:30.0 animate:YES];
73 EXPECT_EQ(30.0, NSWidth([view_ animationEndFrame])); 68 EXPECT_EQ(30.0, NSWidth([view_ animationEndFrame]));
74 69
75 // Test with no animation again. The animationEndFrame should also reflect 70 // Test with no animation again. The animationEndFrame should also reflect
76 // the current frame, if no animation is pending. 71 // the current frame, if no animation is pending.
77 [view_ resizeToWidth:35.0 animate:NO]; 72 [view_ resizeToWidth:35.0 animate:NO];
78 EXPECT_EQ(35.0, NSWidth([view_ frame])); 73 EXPECT_EQ(35.0, NSWidth([view_ frame]));
79 EXPECT_EQ(35.0, NSWidth([view_ animationEndFrame])); 74 EXPECT_EQ(35.0, NSWidth([view_ animationEndFrame]));
80 75
81 BrowserActionsContainerTestDelegate delegate; 76 BrowserActionsContainerTestDelegate delegate;
82 [view_ setDelegate:&delegate]; 77 [view_ setDelegate:&delegate];
83 [view_ resizeToWidth:kMaxAllowedWidthForTest + 10.0 animate:NO]; 78 [view_ resizeToWidth:kMaxAllowedWidthForTest + 10.0 animate:NO];
84 EXPECT_EQ(kMaxAllowedWidthForTest, NSWidth([view_ frame])); 79 EXPECT_EQ(kMaxAllowedWidthForTest, NSWidth([view_ frame]));
85 [view_ setDelegate:nil]; 80 [view_ setDelegate:nil];
86 } 81 }
87 82
88 } // namespace 83 } // namespace
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698