summaryrefslogtreecommitdiffstats
path: root/chrome/browser/ui/cocoa/omnibox/omnibox_popup_cell_unittest.mm
blob: e4bb64b0d6493831e6bd7e8d7a63fbd022aa9600 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
// Copyright (c) 2013 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#import "chrome/browser/ui/cocoa/omnibox/omnibox_popup_cell.h"

#include "base/mac/scoped_nsobject.h"
#import "chrome/browser/ui/cocoa/cocoa_test_helper.h"

namespace {

class OmniboxPopupCellTest : public CocoaTest {
 public:
  OmniboxPopupCellTest() {
  }

  void SetUp() override {
    CocoaTest::SetUp();
    cell_.reset([[OmniboxPopupCell alloc] initTextCell:@""]);
    button_.reset([[NSButton alloc] initWithFrame:NSMakeRect(0, 0, 200, 20)]);
    [button_ setCell:cell_];
    [[test_window() contentView] addSubview:button_];
  };

 protected:
  base::scoped_nsobject<OmniboxPopupCell> cell_;
  base::scoped_nsobject<NSButton> button_;

 private:
  DISALLOW_COPY_AND_ASSIGN(OmniboxPopupCellTest);
};

TEST_VIEW(OmniboxPopupCellTest, button_);

TEST_F(OmniboxPopupCellTest, Image) {
  [cell_ setImage:[NSImage imageNamed:NSImageNameInfo]];
  [button_ display];
}

TEST_F(OmniboxPopupCellTest, Title) {
  base::scoped_nsobject<NSAttributedString> text([[NSAttributedString alloc]
      initWithString:@"The quick brown fox jumps over the lazy dog."]);
  [cell_ setAttributedTitle:text];
  [button_ display];
}

}  // namespace