| 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/mac/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" |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 44 class ToolbarControllerTest : public CocoaProfileTest { | 44 class ToolbarControllerTest : public CocoaProfileTest { |
| 45 public: | 45 public: |
| 46 | 46 |
| 47 // Indexes that match the ordering returned by the private ToolbarController | 47 // Indexes that match the ordering returned by the private ToolbarController |
| 48 // |-toolbarViews| method. | 48 // |-toolbarViews| method. |
| 49 enum { | 49 enum { |
| 50 kBackIndex, kForwardIndex, kReloadIndex, kHomeIndex, | 50 kBackIndex, kForwardIndex, kReloadIndex, kHomeIndex, |
| 51 kWrenchIndex, kLocationIndex, kBrowserActionContainerViewIndex | 51 kWrenchIndex, kLocationIndex, kBrowserActionContainerViewIndex |
| 52 }; | 52 }; |
| 53 | 53 |
| 54 virtual void SetUp() OVERRIDE { | 54 virtual void SetUp() override { |
| 55 CocoaProfileTest::SetUp(); | 55 CocoaProfileTest::SetUp(); |
| 56 ASSERT_TRUE(browser()); | 56 ASSERT_TRUE(browser()); |
| 57 | 57 |
| 58 CommandUpdater* updater = | 58 CommandUpdater* updater = |
| 59 browser()->command_controller()->command_updater(); | 59 browser()->command_controller()->command_updater(); |
| 60 // The default state for the commands is true, set a couple to false to | 60 // The default state for the commands is true, set a couple to false to |
| 61 // ensure they get picked up correct on initialization | 61 // ensure they get picked up correct on initialization |
| 62 updater->UpdateCommandEnabled(IDC_BACK, false); | 62 updater->UpdateCommandEnabled(IDC_BACK, false); |
| 63 updater->UpdateCommandEnabled(IDC_FORWARD, false); | 63 updater->UpdateCommandEnabled(IDC_FORWARD, false); |
| 64 resizeDelegate_.reset([[ViewResizerPong alloc] init]); | 64 resizeDelegate_.reset([[ViewResizerPong alloc] init]); |
| 65 bar_.reset( | 65 bar_.reset( |
| 66 [[ToolbarController alloc] | 66 [[ToolbarController alloc] |
| 67 initWithCommands:browser()->command_controller()->command_updater() | 67 initWithCommands:browser()->command_controller()->command_updater() |
| 68 profile:profile() | 68 profile:profile() |
| 69 browser:browser() | 69 browser:browser() |
| 70 resizeDelegate:resizeDelegate_.get()]); | 70 resizeDelegate:resizeDelegate_.get()]); |
| 71 EXPECT_TRUE([bar_ view]); | 71 EXPECT_TRUE([bar_ view]); |
| 72 NSView* parent = [test_window() contentView]; | 72 NSView* parent = [test_window() contentView]; |
| 73 [parent addSubview:[bar_ view]]; | 73 [parent addSubview:[bar_ view]]; |
| 74 } | 74 } |
| 75 | 75 |
| 76 virtual void TearDown() OVERRIDE { | 76 virtual void TearDown() override { |
| 77 bar_.reset(); // browser() must outlive the ToolbarController. | 77 bar_.reset(); // browser() must outlive the ToolbarController. |
| 78 CocoaProfileTest::TearDown(); | 78 CocoaProfileTest::TearDown(); |
| 79 } | 79 } |
| 80 | 80 |
| 81 // Make sure the enabled state of the view is the same as the corresponding | 81 // Make sure the enabled state of the view is the same as the corresponding |
| 82 // command in the updater. The views are in the declaration order of outlets. | 82 // command in the updater. The views are in the declaration order of outlets. |
| 83 void CompareState(CommandUpdater* updater, NSArray* views) { | 83 void CompareState(CommandUpdater* updater, NSArray* views) { |
| 84 EXPECT_EQ(updater->IsCommandEnabled(IDC_BACK), | 84 EXPECT_EQ(updater->IsCommandEnabled(IDC_BACK), |
| 85 [[views objectAtIndex:kBackIndex] isEnabled] ? true : false); | 85 [[views objectAtIndex:kBackIndex] isEnabled] ? true : false); |
| 86 EXPECT_EQ(updater->IsCommandEnabled(IDC_FORWARD), | 86 EXPECT_EQ(updater->IsCommandEnabled(IDC_FORWARD), |
| (...skipping 160 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 247 EXPECT_FALSE([bar_ hoverButtonForEvent:event]); | 247 EXPECT_FALSE([bar_ hoverButtonForEvent:event]); |
| 248 | 248 |
| 249 // Now! | 249 // Now! |
| 250 base::scoped_nsobject<ImageButtonCell> cell( | 250 base::scoped_nsobject<ImageButtonCell> cell( |
| 251 [[ImageButtonCell alloc] init]); | 251 [[ImageButtonCell alloc] init]); |
| 252 [button setCell:cell.get()]; | 252 [button setCell:cell.get()]; |
| 253 EXPECT_TRUE([bar_ hoverButtonForEvent:nil]); | 253 EXPECT_TRUE([bar_ hoverButtonForEvent:nil]); |
| 254 } | 254 } |
| 255 | 255 |
| 256 } // namespace | 256 } // namespace |
| OLD | NEW |