| OLD | NEW |
| 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 #import <Cocoa/Cocoa.h> | 5 #import <Cocoa/Cocoa.h> |
| 6 | 6 |
| 7 #import "chrome/browser/ui/cocoa/toolbar/reload_button.h" | 7 #import "chrome/browser/ui/cocoa/toolbar/reload_button.h" |
| 8 | 8 |
| 9 #include "base/memory/scoped_nsobject.h" | 9 #include "base/mac/scoped_nsobject.h" |
| 10 #include "chrome/app/chrome_command_ids.h" | 10 #include "chrome/app/chrome_command_ids.h" |
| 11 #import "chrome/browser/ui/cocoa/cocoa_test_helper.h" | 11 #import "chrome/browser/ui/cocoa/cocoa_test_helper.h" |
| 12 #import "chrome/browser/ui/cocoa/image_button_cell.h" | 12 #import "chrome/browser/ui/cocoa/image_button_cell.h" |
| 13 #import "testing/gtest_mac.h" | 13 #import "testing/gtest_mac.h" |
| 14 #include "testing/platform_test.h" | 14 #include "testing/platform_test.h" |
| 15 #import "third_party/ocmock/OCMock/OCMock.h" | 15 #import "third_party/ocmock/OCMock/OCMock.h" |
| 16 #import "ui/base/test/cocoa_test_event_utils.h" | 16 #import "ui/base/test/cocoa_test_event_utils.h" |
| 17 | 17 |
| 18 @interface ReloadButton (Testing) | 18 @interface ReloadButton (Testing) |
| 19 + (void)setPendingReloadTimeout:(NSTimeInterval)seconds; | 19 + (void)setPendingReloadTimeout:(NSTimeInterval)seconds; |
| 20 @end | 20 @end |
| 21 | 21 |
| 22 @protocol TargetActionMock <NSObject> | 22 @protocol TargetActionMock <NSObject> |
| 23 - (void)anAction:(id)sender; | 23 - (void)anAction:(id)sender; |
| 24 @end | 24 @end |
| 25 | 25 |
| 26 namespace { | 26 namespace { |
| 27 | 27 |
| 28 class ReloadButtonTest : public CocoaTest { | 28 class ReloadButtonTest : public CocoaTest { |
| 29 public: | 29 public: |
| 30 ReloadButtonTest() { | 30 ReloadButtonTest() { |
| 31 NSRect frame = NSMakeRect(0, 0, 20, 20); | 31 NSRect frame = NSMakeRect(0, 0, 20, 20); |
| 32 scoped_nsobject<ReloadButton> button( | 32 base::scoped_nsobject<ReloadButton> button( |
| 33 [[ReloadButton alloc] initWithFrame:frame]); | 33 [[ReloadButton alloc] initWithFrame:frame]); |
| 34 button_ = button.get(); | 34 button_ = button.get(); |
| 35 | 35 |
| 36 // Set things up so unit tests have a reliable baseline. | 36 // Set things up so unit tests have a reliable baseline. |
| 37 [button_ setTag:IDC_RELOAD]; | 37 [button_ setTag:IDC_RELOAD]; |
| 38 [button_ awakeFromNib]; | 38 [button_ awakeFromNib]; |
| 39 | 39 |
| 40 [[test_window() contentView] addSubview:button_]; | 40 [[test_window() contentView] addSubview:button_]; |
| 41 } | 41 } |
| 42 | 42 |
| (...skipping 218 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 261 EXPECT_EQ(IDC_STOP, [button_ tag]); | 261 EXPECT_EQ(IDC_STOP, [button_ tag]); |
| 262 EXPECT_FALSE([button_ isEnabled]); | 262 EXPECT_FALSE([button_ isEnabled]); |
| 263 [NSApp postEvent:click.second atStart:YES]; | 263 [NSApp postEvent:click.second atStart:YES]; |
| 264 [button_ mouseDown:click.first]; | 264 [button_ mouseDown:click.first]; |
| 265 EXPECT_EQ(IDC_STOP, [button_ tag]); | 265 EXPECT_EQ(IDC_STOP, [button_ tag]); |
| 266 | 266 |
| 267 [button_ setTarget:nil]; | 267 [button_ setTarget:nil]; |
| 268 } | 268 } |
| 269 | 269 |
| 270 } // namespace | 270 } // namespace |
| OLD | NEW |