OLD | NEW |
---|---|
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 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 "chrome/browser/ui/cocoa/omnibox/omnibox_popup_cell.h" | 5 #import "chrome/browser/ui/cocoa/omnibox/omnibox_popup_cell.h" |
6 | 6 |
7 #include "base/mac/scoped_nsobject.h" | 7 #include "base/mac/scoped_nsobject.h" |
8 #import "chrome/browser/ui/cocoa/cocoa_test_helper.h" | 8 #import "chrome/browser/ui/cocoa/cocoa_test_helper.h" |
9 | 9 |
10 @interface OmniboxPopupCellData () | |
11 - (void)setContents:(NSAttributedString*)contents; | |
12 | |
13 - (void)setImage:(NSImage*)image; | |
14 @end | |
Scott Hess - ex-Googler
2015/05/21 20:40:27
This I'm unsure of. It's comparable to defining a
groby-ooo-7-16
2015/05/22 05:03:07
I'm fine with that crash, since it crashes _tests_
Scott Hess - ex-Googler
2015/05/22 05:17:58
Oh, yes, that's true. If the implementation is on
dschuyler
2015/05/26 18:40:20
Acknowledged.
| |
15 | |
10 namespace { | 16 namespace { |
11 | 17 |
12 class OmniboxPopupCellTest : public CocoaTest { | 18 class OmniboxPopupCellTest : public CocoaTest { |
13 public: | 19 public: |
14 OmniboxPopupCellTest() { | 20 OmniboxPopupCellTest() { |
15 } | 21 } |
16 | 22 |
17 void SetUp() override { | 23 void SetUp() override { |
18 CocoaTest::SetUp(); | 24 CocoaTest::SetUp(); |
19 cell_.reset([[OmniboxPopupCell alloc] initTextCell:@""]); | 25 cellData_.reset([[OmniboxPopupCellData alloc] init]); |
20 button_.reset([[NSButton alloc] initWithFrame:NSMakeRect(0, 0, 200, 20)]); | 26 cell_.reset([[OmniboxPopupCell alloc] init]); |
21 [button_ setCell:cell_]; | 27 [cell_ setRepresentedObject:cellData_]; |
22 [[test_window() contentView] addSubview:button_]; | 28 control_.reset([[NSControl alloc] initWithFrame:NSMakeRect(0, 0, 200, 20)]); |
29 [control_ setCell:cell_]; | |
30 [[test_window() contentView] addSubview:control_]; | |
23 }; | 31 }; |
24 | 32 |
25 protected: | 33 protected: |
34 base::scoped_nsobject<OmniboxPopupCellData> cellData_; | |
26 base::scoped_nsobject<OmniboxPopupCell> cell_; | 35 base::scoped_nsobject<OmniboxPopupCell> cell_; |
27 base::scoped_nsobject<NSButton> button_; | 36 base::scoped_nsobject<NSControl> control_; |
28 | 37 |
29 private: | 38 private: |
30 DISALLOW_COPY_AND_ASSIGN(OmniboxPopupCellTest); | 39 DISALLOW_COPY_AND_ASSIGN(OmniboxPopupCellTest); |
31 }; | 40 }; |
32 | 41 |
33 TEST_VIEW(OmniboxPopupCellTest, button_); | 42 TEST_VIEW(OmniboxPopupCellTest, control_); |
34 | 43 |
35 TEST_F(OmniboxPopupCellTest, Image) { | 44 TEST_F(OmniboxPopupCellTest, Image) { |
36 [cell_ setImage:[NSImage imageNamed:NSImageNameInfo]]; | 45 [cellData_ setImage:[NSImage imageNamed:NSImageNameInfo]]; |
37 [button_ display]; | 46 [control_ display]; |
38 } | 47 } |
39 | 48 |
40 TEST_F(OmniboxPopupCellTest, Title) { | 49 TEST_F(OmniboxPopupCellTest, Title) { |
41 base::scoped_nsobject<NSAttributedString> text([[NSAttributedString alloc] | 50 base::scoped_nsobject<NSAttributedString> text([[NSAttributedString alloc] |
42 initWithString:@"The quick brown fox jumps over the lazy dog."]); | 51 initWithString:@"The quick brown fox jumps over the lazy dog."]); |
43 [cell_ setAttributedTitle:text]; | 52 [cellData_ setContents:text]; |
44 [button_ display]; | 53 [control_ display]; |
45 } | 54 } |
46 | 55 |
47 } // namespace | 56 } // namespace |
OLD | NEW |