| 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 #import "chrome/browser/cocoa/styled_text_field_cell.h" | 8 #import "chrome/browser/cocoa/styled_text_field_cell.h" |
| 9 #import "chrome/browser/cocoa/styled_text_field_test_helper.h" | 9 #import "chrome/browser/cocoa/styled_text_field_test_helper.h" |
| 10 #import "chrome/browser/cocoa/cocoa_test_helper.h" | 10 #import "chrome/browser/cocoa/cocoa_test_helper.h" |
| (...skipping 20 matching lines...) Expand all Loading... |
| 31 [cell_ setBordered:YES]; | 31 [cell_ setBordered:YES]; |
| 32 | 32 |
| 33 scoped_nsobject<NSTextField> view( | 33 scoped_nsobject<NSTextField> view( |
| 34 [[NSTextField alloc] initWithFrame:frame]); | 34 [[NSTextField alloc] initWithFrame:frame]); |
| 35 view_ = view.get(); | 35 view_ = view.get(); |
| 36 [view_ setCell:cell_]; | 36 [view_ setCell:cell_]; |
| 37 | 37 |
| 38 [[test_window() contentView] addSubview:view_]; | 38 [[test_window() contentView] addSubview:view_]; |
| 39 } | 39 } |
| 40 | 40 |
| 41 //CocoaTestHelper cocoa_helper_; // Inits Cocoa, creates window, etc... | |
| 42 NSTextField* view_; | 41 NSTextField* view_; |
| 43 StyledTextFieldTestCell* cell_; | 42 StyledTextFieldTestCell* cell_; |
| 44 }; | 43 }; |
| 45 | 44 |
| 46 // Basic view tests (AddRemove, Display). | 45 // Basic view tests (AddRemove, Display). |
| 47 TEST_VIEW(StyledTextFieldCellTest, view_); | 46 TEST_VIEW(StyledTextFieldCellTest, view_); |
| 48 | 47 |
| 49 // Test drawing, mostly to ensure nothing leaks or crashes. | 48 // Test drawing, mostly to ensure nothing leaks or crashes. |
| 50 TEST_F(StyledTextFieldCellTest, FocusedDisplay) { | 49 TEST_F(StyledTextFieldCellTest, FocusedDisplay) { |
| 51 [view_ display]; | 50 [view_ display]; |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 88 EXPECT_TRUE(NSContainsRect(NSInsetRect(textFrame, 1, 1), drawingRect)); | 87 EXPECT_TRUE(NSContainsRect(NSInsetRect(textFrame, 1, 1), drawingRect)); |
| 89 | 88 |
| 90 [cell_ setLeftMargin:0]; | 89 [cell_ setLeftMargin:0]; |
| 91 textFrame = [cell_ textFrameForFrame:bounds]; | 90 textFrame = [cell_ textFrameForFrame:bounds]; |
| 92 drawingRect = [cell_ drawingRectForBounds:bounds]; | 91 drawingRect = [cell_ drawingRectForBounds:bounds]; |
| 93 EXPECT_FALSE(NSIsEmptyRect(drawingRect)); | 92 EXPECT_FALSE(NSIsEmptyRect(drawingRect)); |
| 94 EXPECT_TRUE(NSContainsRect(NSInsetRect(textFrame, 1, 1), drawingRect)); | 93 EXPECT_TRUE(NSContainsRect(NSInsetRect(textFrame, 1, 1), drawingRect)); |
| 95 } | 94 } |
| 96 | 95 |
| 97 } // namespace | 96 } // namespace |
| OLD | NEW |