| 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 #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 143 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 154 // IDC_RELOAD. When loading, it should be IDC_STOP. | 154 // IDC_RELOAD. When loading, it should be IDC_STOP. |
| 155 NSButton* reload = [[bar_ toolbarViews] objectAtIndex:kReloadIndex]; | 155 NSButton* reload = [[bar_ toolbarViews] objectAtIndex:kReloadIndex]; |
| 156 EXPECT_EQ([reload tag], IDC_RELOAD); | 156 EXPECT_EQ([reload tag], IDC_RELOAD); |
| 157 [bar_ setIsLoading:YES force:YES]; | 157 [bar_ setIsLoading:YES force:YES]; |
| 158 EXPECT_EQ([reload tag], IDC_STOP); | 158 EXPECT_EQ([reload tag], IDC_STOP); |
| 159 [bar_ setIsLoading:NO force:YES]; | 159 [bar_ setIsLoading:NO force:YES]; |
| 160 EXPECT_EQ([reload tag], IDC_RELOAD); | 160 EXPECT_EQ([reload tag], IDC_RELOAD); |
| 161 } | 161 } |
| 162 | 162 |
| 163 // Check that toggling the state of the home button changes the visible | 163 // Check that toggling the state of the home button changes the visible |
| 164 // state of the home button and moves the other buttons accordingly. | 164 // state of the home button and moves the other items accordingly. |
| 165 TEST_F(ToolbarControllerTest, ToggleHome) { | 165 TEST_F(ToolbarControllerTest, ToggleHome) { |
| 166 PrefService* prefs = helper_.profile()->GetPrefs(); | 166 PrefService* prefs = helper_.profile()->GetPrefs(); |
| 167 bool showHome = prefs->GetBoolean(prefs::kShowHomeButton); | 167 bool showHome = prefs->GetBoolean(prefs::kShowHomeButton); |
| 168 NSView* homeButton = [[bar_ toolbarViews] objectAtIndex:kHomeIndex]; | 168 NSView* homeButton = [[bar_ toolbarViews] objectAtIndex:kHomeIndex]; |
| 169 EXPECT_EQ(showHome, ![homeButton isHidden]); | 169 EXPECT_EQ(showHome, ![homeButton isHidden]); |
| 170 | 170 |
| 171 NSView* reloadButton = [[bar_ toolbarViews] objectAtIndex:kReloadIndex]; | |
| 172 NSView* locationBar = [[bar_ toolbarViews] objectAtIndex:kLocationIndex]; | 171 NSView* locationBar = [[bar_ toolbarViews] objectAtIndex:kLocationIndex]; |
| 173 NSRect originalReloadFrame = [reloadButton frame]; | |
| 174 NSRect originalLocationBarFrame = [locationBar frame]; | 172 NSRect originalLocationBarFrame = [locationBar frame]; |
| 175 | 173 |
| 176 // Toggle the pref and make sure the button changed state and the other | 174 // Toggle the pref and make sure the button changed state and the other |
| 177 // views moved. | 175 // views moved. |
| 178 prefs->SetBoolean(prefs::kShowHomeButton, !showHome); | 176 prefs->SetBoolean(prefs::kShowHomeButton, !showHome); |
| 179 EXPECT_EQ(showHome, [homeButton isHidden]); | 177 EXPECT_EQ(showHome, [homeButton isHidden]); |
| 180 EXPECT_NE(NSMinX(originalReloadFrame), NSMinX([reloadButton frame])); | |
| 181 EXPECT_NE(NSMinX(originalLocationBarFrame), NSMinX([locationBar frame])); | 178 EXPECT_NE(NSMinX(originalLocationBarFrame), NSMinX([locationBar frame])); |
| 182 EXPECT_NE(NSWidth(originalLocationBarFrame), NSWidth([locationBar frame])); | 179 EXPECT_NE(NSWidth(originalLocationBarFrame), NSWidth([locationBar frame])); |
| 183 } | 180 } |
| 184 | 181 |
| 185 // Ensure that we don't toggle the buttons when we have a strip marked as not | 182 // Ensure that we don't toggle the buttons when we have a strip marked as not |
| 186 // having the full toolbar. Also ensure that the location bar doesn't change | 183 // having the full toolbar. Also ensure that the location bar doesn't change |
| 187 // size. | 184 // size. |
| 188 TEST_F(ToolbarControllerTest, DontToggleWhenNoToolbar) { | 185 TEST_F(ToolbarControllerTest, DontToggleWhenNoToolbar) { |
| 189 [bar_ setHasToolbar:NO hasLocationBar:YES]; | 186 [bar_ setHasToolbar:NO hasLocationBar:YES]; |
| 190 NSView* homeButton = [[bar_ toolbarViews] objectAtIndex:kHomeIndex]; | 187 NSView* homeButton = [[bar_ toolbarViews] objectAtIndex:kHomeIndex]; |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 231 [view setHitTestReturn:button]; | 228 [view setHitTestReturn:button]; |
| 232 EXPECT_FALSE([bar_ hoverButtonForEvent:event]); | 229 EXPECT_FALSE([bar_ hoverButtonForEvent:event]); |
| 233 | 230 |
| 234 // Now! | 231 // Now! |
| 235 scoped_nsobject<GradientButtonCell> cell([[GradientButtonCell alloc] init]); | 232 scoped_nsobject<GradientButtonCell> cell([[GradientButtonCell alloc] init]); |
| 236 [button setCell:cell.get()]; | 233 [button setCell:cell.get()]; |
| 237 EXPECT_TRUE([bar_ hoverButtonForEvent:nil]); | 234 EXPECT_TRUE([bar_ hoverButtonForEvent:nil]); |
| 238 } | 235 } |
| 239 | 236 |
| 240 } // namespace | 237 } // namespace |
| OLD | NEW |