Add ICU message format support
[chromium-blink-merge.git] / ui / message_center / cocoa / status_item_view_unittest.mm
blob1e68770c0566cf806529002e0249fb42fd3596a7
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
3 // found in the LICENSE file.
5 #import "ui/message_center/cocoa/status_item_view.h"
7 #include "base/mac/scoped_nsobject.h"
8 #import "ui/gfx/test/ui_cocoa_test_helper.h"
10 class StatusItemViewTest : public ui::CocoaTest {
11  public:
12   StatusItemViewTest()
13       : view_([[MCStatusItemView alloc] init]) {
14   }
16   void SetUp() override {
17     ui::CocoaTest::SetUp();
18     [[test_window() contentView] addSubview:view_];
19   }
21   void TearDown() override {
22     [view_ removeItem];
23     ui::CocoaTest::TearDown();
24   }
26  protected:
27   base::scoped_nsobject<MCStatusItemView> view_;
30 // These tests are like TEST_VIEW() but set some of the properties.
32 TEST_F(StatusItemViewTest, Callback) {
33   __block BOOL got_callback = NO;
34   [view_ setCallback:^{
35       got_callback = YES;
36   }];
37   [view_ mouseDown:nil];
38   EXPECT_TRUE(got_callback);
39   [view_ mouseUp:nil];
41   got_callback = NO;
42   [view_ rightMouseDown:nil];
43   EXPECT_TRUE(got_callback);
44   [view_ rightMouseUp:nil];
46   got_callback = NO;
47   [view_ otherMouseDown:nil];
48   EXPECT_TRUE(got_callback);
49   [view_ otherMouseUp:nil];
52 TEST_F(StatusItemViewTest, UnreadCount) {
53   CGFloat initial_width = NSWidth([view_ frame]);
55   [view_ setUnreadCount:2 withQuietMode:NO];
56   [view_ display];
57   EXPECT_EQ(NSWidth([view_ frame]), initial_width);
59   [view_ setUnreadCount:0 withQuietMode:NO];
60   [view_ display];
61   EXPECT_EQ(NSWidth([view_ frame]), initial_width);
63   [view_ setUnreadCount:1000 withQuietMode:YES];
64   [view_ display];
65   EXPECT_EQ(NSWidth([view_ frame]), initial_width);
67   [view_ setUnreadCount:0 withQuietMode:YES];
68   [view_ display];
69   EXPECT_EQ(NSWidth([view_ frame]), initial_width);
72 TEST_F(StatusItemViewTest, Highlight) {
73   [view_ setHighlight:YES];
74   [view_ display];
75   [view_ setHighlight:NO];
76   [view_ display];
79 TEST_F(StatusItemViewTest, HighlightAndMouseEvent) {
80   [view_ mouseDown:nil];
81   [view_ display];
82   [view_ setHighlight:YES];
83   [view_ display];
84   [view_ mouseUp:nil];
85   [view_ display];
86   [view_ setHighlight:NO];
87   [view_ display];