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 {
13 : view_([[MCStatusItemView alloc] init]) {
16 void SetUp() override {
17 ui::CocoaTest::SetUp();
18 [[test_window() contentView] addSubview:view_];
21 void TearDown() override {
23 ui::CocoaTest::TearDown();
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;
37 [view_ mouseDown:nil];
38 EXPECT_TRUE(got_callback);
42 [view_ rightMouseDown:nil];
43 EXPECT_TRUE(got_callback);
44 [view_ rightMouseUp:nil];
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];
57 EXPECT_EQ(NSWidth([view_ frame]), initial_width);
59 [view_ setUnreadCount:0 withQuietMode:NO];
61 EXPECT_EQ(NSWidth([view_ frame]), initial_width);
63 [view_ setUnreadCount:1000 withQuietMode:YES];
65 EXPECT_EQ(NSWidth([view_ frame]), initial_width);
67 [view_ setUnreadCount:0 withQuietMode:YES];
69 EXPECT_EQ(NSWidth([view_ frame]), initial_width);
72 TEST_F(StatusItemViewTest, Highlight) {
73 [view_ setHighlight:YES];
75 [view_ setHighlight:NO];
79 TEST_F(StatusItemViewTest, HighlightAndMouseEvent) {
80 [view_ mouseDown:nil];
82 [view_ setHighlight:YES];
86 [view_ setHighlight:NO];