| 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 #include "base/scoped_nsobject.h" | 7 #include "base/scoped_nsobject.h" |
| 8 #include "base/string_util.h" | 8 #include "base/string_util.h" |
| 9 #include "base/sys_string_conversions.h" | 9 #include "base/sys_string_conversions.h" |
| 10 #import "chrome/browser/cocoa/cocoa_test_helper.h" | 10 #import "chrome/browser/cocoa/cocoa_test_helper.h" |
| (...skipping 12 matching lines...) Expand all Loading... |
| 23 @implementation InfoBarController (ExposedForTesting) | 23 @implementation InfoBarController (ExposedForTesting) |
| 24 - (NSString*)labelString { | 24 - (NSString*)labelString { |
| 25 return [label_.get() string]; | 25 return [label_.get() string]; |
| 26 } | 26 } |
| 27 - (NSRect)labelFrame { | 27 - (NSRect)labelFrame { |
| 28 return [label_.get() frame]; | 28 return [label_.get() frame]; |
| 29 } | 29 } |
| 30 @end | 30 @end |
| 31 | 31 |
| 32 | 32 |
| 33 // Calls to removeDelegate: normally start an animation, which removes the | 33 // Calls to removeDelegate: normally (a) start an animation, which removes the |
| 34 // infobar completely when finished. For unittesting purposes, we create a mock | 34 // infobar completely when finished; and (b) synchronously close the delegate. |
| 35 // container which calls close: immediately, rather than kicking off an | 35 // For unittesting purposes, we create a mock container which calls close: |
| 36 // animation. | 36 // immediately, rather than kicking off an animation; the delegate is still |
| 37 // closed synchronously. |
| 37 @interface InfoBarContainerTest : NSObject <InfoBarContainer> { | 38 @interface InfoBarContainerTest : NSObject <InfoBarContainer> { |
| 38 InfoBarController* controller_; | 39 InfoBarController* controller_; |
| 39 } | 40 } |
| 40 - (id)initWithController:(InfoBarController*)controller; | 41 - (id)initWithController:(InfoBarController*)controller; |
| 41 - (void)removeDelegate:(InfoBarDelegate*)delegate; | 42 - (void)removeDelegate:(InfoBarDelegate*)delegate; |
| 42 - (void)removeController:(InfoBarController*)controller; | 43 - (void)removeController:(InfoBarController*)controller; |
| 43 @end | 44 @end |
| 44 | 45 |
| 45 @implementation InfoBarContainerTest | 46 @implementation InfoBarContainerTest |
| 46 - (id)initWithController:(InfoBarController*)controller { | 47 - (id)initWithController:(InfoBarController*)controller { |
| 47 if ((self = [super init])) { | 48 if ((self = [super init])) { |
| 48 controller_ = controller; | 49 controller_ = controller; |
| 49 } | 50 } |
| 50 return self; | 51 return self; |
| 51 } | 52 } |
| 52 | 53 |
| 53 - (void)removeDelegate:(InfoBarDelegate*)delegate { | 54 - (void)removeDelegate:(InfoBarDelegate*)delegate { |
| 54 [controller_ close]; | 55 [controller_ close]; |
| 56 delegate->InfoBarClosed(); |
| 55 } | 57 } |
| 56 | 58 |
| 57 - (void)removeController:(InfoBarController*)controller { | 59 - (void)removeController:(InfoBarController*)controller { |
| 58 DCHECK(controller_ == controller); | 60 DCHECK(controller_ == controller); |
| 59 controller_ = nil; | 61 controller_ = nil; |
| 60 } | 62 } |
| 61 @end | 63 @end |
| 62 | 64 |
| 63 namespace { | 65 namespace { |
| 64 | 66 |
| (...skipping 210 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 275 // Check that clicking on the link calls LinkClicked() on the | 277 // Check that clicking on the link calls LinkClicked() on the |
| 276 // delegate. It should not close the infobar. | 278 // delegate. It should not close the infobar. |
| 277 [controller_ linkClicked]; | 279 [controller_ linkClicked]; |
| 278 EXPECT_FALSE(delegate_.ok_clicked); | 280 EXPECT_FALSE(delegate_.ok_clicked); |
| 279 EXPECT_FALSE(delegate_.cancel_clicked); | 281 EXPECT_FALSE(delegate_.cancel_clicked); |
| 280 EXPECT_TRUE(delegate_.link_clicked); | 282 EXPECT_TRUE(delegate_.link_clicked); |
| 281 EXPECT_FALSE(delegate_.closed); | 283 EXPECT_FALSE(delegate_.closed); |
| 282 } | 284 } |
| 283 | 285 |
| 284 } // namespace | 286 } // namespace |
| OLD | NEW |