| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/memory/scoped_nsobject.h" | 7 #import "base/mac/scoped_nsobject.h" |
| 8 #include "base/prefs/pref_service.h" | 8 #include "base/prefs/pref_service.h" |
| 9 #include "chrome/app/chrome_command_ids.h" | 9 #include "chrome/app/chrome_command_ids.h" |
| 10 #include "chrome/browser/command_updater.h" | 10 #include "chrome/browser/command_updater.h" |
| 11 #include "chrome/browser/ui/browser_command_controller.h" | 11 #include "chrome/browser/ui/browser_command_controller.h" |
| 12 #include "chrome/browser/ui/browser_commands.h" | 12 #include "chrome/browser/ui/browser_commands.h" |
| 13 #include "chrome/browser/ui/cocoa/cocoa_profile_test.h" | 13 #include "chrome/browser/ui/cocoa/cocoa_profile_test.h" |
| 14 #import "chrome/browser/ui/cocoa/gradient_button_cell.h" | 14 #import "chrome/browser/ui/cocoa/gradient_button_cell.h" |
| 15 #import "chrome/browser/ui/cocoa/toolbar/toolbar_controller.h" | 15 #import "chrome/browser/ui/cocoa/toolbar/toolbar_controller.h" |
| 16 #import "chrome/browser/ui/cocoa/view_resizer_pong.h" | 16 #import "chrome/browser/ui/cocoa/view_resizer_pong.h" |
| 17 #include "chrome/common/pref_names.h" | 17 #include "chrome/common/pref_names.h" |
| (...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 82 EXPECT_EQ(updater->IsCommandEnabled(IDC_BACK), | 82 EXPECT_EQ(updater->IsCommandEnabled(IDC_BACK), |
| 83 [[views objectAtIndex:kBackIndex] isEnabled] ? true : false); | 83 [[views objectAtIndex:kBackIndex] isEnabled] ? true : false); |
| 84 EXPECT_EQ(updater->IsCommandEnabled(IDC_FORWARD), | 84 EXPECT_EQ(updater->IsCommandEnabled(IDC_FORWARD), |
| 85 [[views objectAtIndex:kForwardIndex] isEnabled] ? true : false); | 85 [[views objectAtIndex:kForwardIndex] isEnabled] ? true : false); |
| 86 EXPECT_EQ(updater->IsCommandEnabled(IDC_RELOAD), | 86 EXPECT_EQ(updater->IsCommandEnabled(IDC_RELOAD), |
| 87 [[views objectAtIndex:kReloadIndex] isEnabled] ? true : false); | 87 [[views objectAtIndex:kReloadIndex] isEnabled] ? true : false); |
| 88 EXPECT_EQ(updater->IsCommandEnabled(IDC_HOME), | 88 EXPECT_EQ(updater->IsCommandEnabled(IDC_HOME), |
| 89 [[views objectAtIndex:kHomeIndex] isEnabled] ? true : false); | 89 [[views objectAtIndex:kHomeIndex] isEnabled] ? true : false); |
| 90 } | 90 } |
| 91 | 91 |
| 92 scoped_nsobject<ViewResizerPong> resizeDelegate_; | 92 base::scoped_nsobject<ViewResizerPong> resizeDelegate_; |
| 93 scoped_nsobject<ToolbarController> bar_; | 93 base::scoped_nsobject<ToolbarController> bar_; |
| 94 }; | 94 }; |
| 95 | 95 |
| 96 TEST_VIEW(ToolbarControllerTest, [bar_ view]) | 96 TEST_VIEW(ToolbarControllerTest, [bar_ view]) |
| 97 | 97 |
| 98 // Test the initial state that everything is sync'd up | 98 // Test the initial state that everything is sync'd up |
| 99 TEST_F(ToolbarControllerTest, InitialState) { | 99 TEST_F(ToolbarControllerTest, InitialState) { |
| 100 CommandUpdater* updater = browser()->command_controller()->command_updater(); | 100 CommandUpdater* updater = browser()->command_controller()->command_updater(); |
| 101 CompareState(updater, [bar_ toolbarViews]); | 101 CompareState(updater, [bar_ toolbarViews]); |
| 102 } | 102 } |
| 103 | 103 |
| (...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 208 TEST_F(ToolbarControllerTest, BookmarkBubblePoint) { | 208 TEST_F(ToolbarControllerTest, BookmarkBubblePoint) { |
| 209 const NSPoint starPoint = [bar_ bookmarkBubblePoint]; | 209 const NSPoint starPoint = [bar_ bookmarkBubblePoint]; |
| 210 const NSRect barFrame = | 210 const NSRect barFrame = |
| 211 [[bar_ view] convertRect:[[bar_ view] bounds] toView:nil]; | 211 [[bar_ view] convertRect:[[bar_ view] bounds] toView:nil]; |
| 212 | 212 |
| 213 // Make sure the star is completely inside the location bar. | 213 // Make sure the star is completely inside the location bar. |
| 214 EXPECT_TRUE(NSPointInRect(starPoint, barFrame)); | 214 EXPECT_TRUE(NSPointInRect(starPoint, barFrame)); |
| 215 } | 215 } |
| 216 | 216 |
| 217 TEST_F(ToolbarControllerTest, HoverButtonForEvent) { | 217 TEST_F(ToolbarControllerTest, HoverButtonForEvent) { |
| 218 scoped_nsobject<HitView> view([[HitView alloc] | 218 base::scoped_nsobject<HitView> view( |
| 219 initWithFrame:NSMakeRect(0,0,100,100)]); | 219 [[HitView alloc] initWithFrame:NSMakeRect(0, 0, 100, 100)]); |
| 220 [bar_ setView:view]; | 220 [bar_ setView:view]; |
| 221 NSEvent* event = [NSEvent mouseEventWithType:NSMouseMoved | 221 NSEvent* event = [NSEvent mouseEventWithType:NSMouseMoved |
| 222 location:NSMakePoint(10,10) | 222 location:NSMakePoint(10,10) |
| 223 modifierFlags:0 | 223 modifierFlags:0 |
| 224 timestamp:0 | 224 timestamp:0 |
| 225 windowNumber:0 | 225 windowNumber:0 |
| 226 context:nil | 226 context:nil |
| 227 eventNumber:0 | 227 eventNumber:0 |
| 228 clickCount:0 | 228 clickCount:0 |
| 229 pressure:0.0]; | 229 pressure:0.0]; |
| 230 | 230 |
| 231 // NOT a match. | 231 // NOT a match. |
| 232 [view setHitTestReturn:bar_.get()]; | 232 [view setHitTestReturn:bar_.get()]; |
| 233 EXPECT_FALSE([bar_ hoverButtonForEvent:event]); | 233 EXPECT_FALSE([bar_ hoverButtonForEvent:event]); |
| 234 | 234 |
| 235 // Not yet... | 235 // Not yet... |
| 236 scoped_nsobject<NSButton> button([[NSButton alloc] init]); | 236 base::scoped_nsobject<NSButton> button([[NSButton alloc] init]); |
| 237 [view setHitTestReturn:button]; | 237 [view setHitTestReturn:button]; |
| 238 EXPECT_FALSE([bar_ hoverButtonForEvent:event]); | 238 EXPECT_FALSE([bar_ hoverButtonForEvent:event]); |
| 239 | 239 |
| 240 // Now! | 240 // Now! |
| 241 scoped_nsobject<GradientButtonCell> cell([[GradientButtonCell alloc] init]); | 241 base::scoped_nsobject<GradientButtonCell> cell( |
| 242 [[GradientButtonCell alloc] init]); |
| 242 [button setCell:cell.get()]; | 243 [button setCell:cell.get()]; |
| 243 EXPECT_TRUE([bar_ hoverButtonForEvent:nil]); | 244 EXPECT_TRUE([bar_ hoverButtonForEvent:nil]); |
| 244 } | 245 } |
| 245 | 246 |
| 246 } // namespace | 247 } // namespace |
| OLD | NEW |