OLD | NEW |
(Empty) | |
| 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 |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #import <Cocoa/Cocoa.h> |
| 6 |
| 7 #include "chrome/browser/cocoa/cocoa_test_helper.h" |
| 8 #import "chrome/browser/cocoa/infobar_text_field.h" |
| 9 #include "testing/gtest/include/gtest/gtest.h" |
| 10 #include "testing/platform_test.h" |
| 11 |
| 12 @interface TextFieldDelegatePong: NSObject { |
| 13 @private |
| 14 BOOL pong_; |
| 15 } |
| 16 @property(readonly) BOOL pong; |
| 17 @end |
| 18 |
| 19 @implementation TextFieldDelegatePong |
| 20 @synthesize pong = pong_; |
| 21 |
| 22 - (id)init { |
| 23 if ((self == [super init])) { |
| 24 pong_ = NO; |
| 25 } |
| 26 return self; |
| 27 } |
| 28 |
| 29 - (void)linkClicked { |
| 30 pong_ = YES; |
| 31 } |
| 32 @end |
| 33 |
| 34 namespace { |
| 35 |
| 36 /////////////////////////////////////////////////////////////////////////// |
| 37 // Test fixtures |
| 38 |
| 39 class InfoBarTextFieldTest : public PlatformTest { |
| 40 protected: |
| 41 CocoaTestHelper helper_; |
| 42 }; |
| 43 |
| 44 //////////////////////////////////////////////////////////////////////////// |
| 45 // Tests |
| 46 |
| 47 TEST_F(InfoBarTextFieldTest, Show) { |
| 48 // Test basic drawing. |
| 49 scoped_nsobject<InfoBarTextField> field( |
| 50 [[InfoBarTextField alloc] initWithFrame:NSMakeRect(0, 0, 200, 200)]); |
| 51 [helper_.contentView() addSubview:field]; |
| 52 } |
| 53 |
| 54 TEST_F(InfoBarTextFieldTest, LinkClicked) { |
| 55 scoped_nsobject<InfoBarTextField> field( |
| 56 [[InfoBarTextField alloc] initWithFrame:NSMakeRect(0, 0, 200, 200)]); |
| 57 scoped_nsobject<TextFieldDelegatePong> delegate( |
| 58 [[TextFieldDelegatePong alloc] init]); |
| 59 [field setDelegate:delegate]; |
| 60 |
| 61 // Our implementation doesn't look at any of these fields, so they |
| 62 // can all be nil. |
| 63 [field textView:nil clickedOnLink:nil atIndex:0]; |
| 64 EXPECT_TRUE([delegate pong]); |
| 65 } |
| 66 |
| 67 } // namespace |
OLD | NEW |