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 "ui/message_center/cocoa/status_item_view.h" | 5 #import "ui/message_center/cocoa/status_item_view.h" |
6 | 6 |
7 #include "base/memory/scoped_nsobject.h" | 7 #include "base/memory/scoped_nsobject.h" |
8 #import "ui/base/test/ui_cocoa_test_helper.h" | 8 #import "ui/base/test/ui_cocoa_test_helper.h" |
9 | 9 |
10 class StatusItemViewTest : public ui::CocoaTest { | 10 class StatusItemViewTest : public ui::CocoaTest { |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
47 EXPECT_TRUE(got_callback); | 47 EXPECT_TRUE(got_callback); |
48 [view_ rightMouseUp:nil]; | 48 [view_ rightMouseUp:nil]; |
49 | 49 |
50 got_callback = NO; | 50 got_callback = NO; |
51 [view_ otherMouseDown:nil]; | 51 [view_ otherMouseDown:nil]; |
52 EXPECT_TRUE(got_callback); | 52 EXPECT_TRUE(got_callback); |
53 [view_ otherMouseUp:nil]; | 53 [view_ otherMouseUp:nil]; |
54 } | 54 } |
55 | 55 |
56 TEST_F(StatusItemViewTest, UnreadCount) { | 56 TEST_F(StatusItemViewTest, UnreadCount) { |
| 57 CGFloat initial_width = NSWidth([view_ frame]); |
| 58 |
| 59 CGFloat width = initial_width; |
57 [view_ setUnreadCount:2]; | 60 [view_ setUnreadCount:2]; |
58 [view_ display]; | 61 [view_ display]; |
| 62 EXPECT_GT(NSWidth([view_ frame]), width); |
| 63 width = NSWidth([view_ frame]); |
| 64 |
59 [view_ setUnreadCount:10]; | 65 [view_ setUnreadCount:10]; |
60 [view_ display]; | 66 [view_ display]; |
| 67 EXPECT_GT(NSWidth([view_ frame]), width); |
| 68 width = NSWidth([view_ frame]); |
| 69 |
| 70 CGFloat max_width = width; |
| 71 |
61 [view_ setUnreadCount:0]; | 72 [view_ setUnreadCount:0]; |
62 [view_ display]; | 73 [view_ display]; |
| 74 EXPECT_LT(NSWidth([view_ frame]), width); |
| 75 width = NSWidth([view_ frame]); |
| 76 EXPECT_CGFLOAT_EQ(width, initial_width); |
| 77 |
63 [view_ setUnreadCount:1000]; | 78 [view_ setUnreadCount:1000]; |
64 [view_ display]; | 79 [view_ display]; |
| 80 EXPECT_GT(NSWidth([view_ frame]), width); |
| 81 width = NSWidth([view_ frame]); |
| 82 EXPECT_CGFLOAT_EQ(width, max_width); |
65 } | 83 } |
66 | 84 |
67 TEST_F(StatusItemViewTest, Highlight) { | 85 TEST_F(StatusItemViewTest, Highlight) { |
68 [view_ setHighlight:YES]; | 86 [view_ setHighlight:YES]; |
69 [view_ display]; | 87 [view_ display]; |
70 [view_ setHighlight:NO]; | 88 [view_ setHighlight:NO]; |
71 [view_ display]; | 89 [view_ display]; |
72 } | 90 } |
73 | 91 |
74 TEST_F(StatusItemViewTest, HighlightAndMouseEvent) { | 92 TEST_F(StatusItemViewTest, HighlightAndMouseEvent) { |
75 [view_ mouseDown:nil]; | 93 [view_ mouseDown:nil]; |
76 [view_ display]; | 94 [view_ display]; |
77 [view_ setHighlight:YES]; | 95 [view_ setHighlight:YES]; |
78 [view_ display]; | 96 [view_ display]; |
79 [view_ mouseUp:nil]; | 97 [view_ mouseUp:nil]; |
80 [view_ display]; | 98 [view_ display]; |
81 [view_ setHighlight:NO]; | 99 [view_ setHighlight:NO]; |
82 [view_ display]; | 100 [view_ display]; |
83 } | 101 } |
OLD | NEW |