OLD | NEW |
1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009 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 #import <Cocoa/Cocoa.h> | 5 #import <Cocoa/Cocoa.h> |
6 | 6 |
7 #import "base/scoped_nsobject.h" | 7 #import "base/scoped_nsobject.h" |
8 #include "chrome/app/chrome_dll_resource.h" | 8 #include "chrome/app/chrome_dll_resource.h" |
9 #include "chrome/browser/cocoa/browser_test_helper.h" | 9 #include "chrome/browser/cocoa/browser_test_helper.h" |
10 #import "chrome/browser/cocoa/cocoa_test_helper.h" | 10 #import "chrome/browser/cocoa/cocoa_test_helper.h" |
(...skipping 177 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
188 | 188 |
189 // Toggle the pref and make sure the buttons changed state and the other | 189 // Toggle the pref and make sure the buttons changed state and the other |
190 // views moved (or in the case of the location bar, it changed width). | 190 // views moved (or in the case of the location bar, it changed width). |
191 prefs->SetBoolean(prefs::kShowPageOptionsButtons, !showButtons); | 191 prefs->SetBoolean(prefs::kShowPageOptionsButtons, !showButtons); |
192 EXPECT_EQ(showButtons, [pageButton isHidden]); | 192 EXPECT_EQ(showButtons, [pageButton isHidden]); |
193 EXPECT_EQ(showButtons, [wrenchButton isHidden]); | 193 EXPECT_EQ(showButtons, [wrenchButton isHidden]); |
194 EXPECT_NE(NSMinX(originalGoFrame), NSMinX([goButton frame])); | 194 EXPECT_NE(NSMinX(originalGoFrame), NSMinX([goButton frame])); |
195 EXPECT_NE(NSWidth(originalLocationBarFrame), NSWidth([locationBar frame])); | 195 EXPECT_NE(NSWidth(originalLocationBarFrame), NSWidth([locationBar frame])); |
196 } | 196 } |
197 | 197 |
| 198 TEST_F(ToolbarControllerTest, BookmarkBarResizes) { |
| 199 NSView* bookmarkBarView = [[bar_ bookmarkBarController] view]; |
| 200 ASSERT_EQ(0, NSHeight([bookmarkBarView frame])); |
| 201 [resizeDelegate_ setHeight:-1]; |
| 202 |
| 203 // Resize the bookmarkbar to 30px. The toolbar should ask the delegate to |
| 204 // resize to 64px. |
| 205 [bar_ resizeView:bookmarkBarView newHeight:30]; |
| 206 EXPECT_EQ(64, [resizeDelegate_ height]); |
| 207 EXPECT_EQ(30, NSHeight([bookmarkBarView frame])); |
| 208 |
| 209 // Resize the bookmarkbar back to 0px. Toolbar should be at 39px. |
| 210 [bar_ resizeView:bookmarkBarView newHeight:0]; |
| 211 EXPECT_EQ(39, [resizeDelegate_ height]); |
| 212 EXPECT_EQ(0, NSHeight([bookmarkBarView frame])); |
| 213 |
| 214 // Resize the bookmarkbar to 5px. Toolbar should stay at 39px. |
| 215 [resizeDelegate_ setHeight:-1]; |
| 216 [bar_ resizeView:bookmarkBarView newHeight:5]; |
| 217 EXPECT_EQ(39, [resizeDelegate_ height]); |
| 218 EXPECT_EQ(5, NSHeight([bookmarkBarView frame])); |
| 219 |
| 220 // Resize the bookmarkbar to 6px. Toolbar should grow to 40px. |
| 221 [bar_ resizeView:bookmarkBarView newHeight:6]; |
| 222 EXPECT_EQ(40, [resizeDelegate_ height]); |
| 223 EXPECT_EQ(6, NSHeight([bookmarkBarView frame])); |
| 224 } |
| 225 |
198 // Make sure, by default, the bookmark bar is the full width of the | 226 // Make sure, by default, the bookmark bar is the full width of the |
199 // toolbar. | 227 // toolbar. |
200 TEST_F(ToolbarControllerTest, BookmarkBarIsFullWidth) { | 228 TEST_F(ToolbarControllerTest, BookmarkBarIsFullWidth) { |
201 // Set the pref to the bookmark bar is visible when the toolbar is | 229 // Set the pref to the bookmark bar is visible when the toolbar is |
202 // first created. | 230 // first created. |
203 helper_.profile()->GetPrefs()->SetBoolean(prefs::kShowBookmarkBar, true); | 231 helper_.profile()->GetPrefs()->SetBoolean(prefs::kShowBookmarkBar, true); |
204 | 232 |
205 // Create a new bar (after the pref is set) | 233 // Create a new bar (after the pref is set) |
206 Browser* browser = helper_.browser(); | 234 Browser* browser = helper_.browser(); |
207 bar_.reset( | 235 bar_.reset( |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
244 EXPECT_LT(popupFrame.x(), NSMinX(locationFrame)); | 272 EXPECT_LT(popupFrame.x(), NSMinX(locationFrame)); |
245 EXPECT_GT(popupFrame.right(), NSMaxX(locationFrame)); | 273 EXPECT_GT(popupFrame.right(), NSMaxX(locationFrame)); |
246 | 274 |
247 // Make sure the popup frame is positioned at the bottom of the location bar. | 275 // Make sure the popup frame is positioned at the bottom of the location bar. |
248 EXPECT_EQ(popupFrame.bottom(), NSMinY(locationFrame)); | 276 EXPECT_EQ(popupFrame.bottom(), NSMinY(locationFrame)); |
249 } | 277 } |
250 | 278 |
251 | 279 |
252 | 280 |
253 } // namespace | 281 } // namespace |
OLD | NEW |