Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(26)

Side by Side Diff: ui/message_center/cocoa/status_item_view_unittest.mm

Issue 1334363002: [Eraser] First pass at removing the notification center panel. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Moar fix Created 5 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(Empty)
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.
4
5 #import "ui/message_center/cocoa/status_item_view.h"
6
7 #include "base/mac/scoped_nsobject.h"
8 #import "ui/gfx/test/ui_cocoa_test_helper.h"
9
10 class StatusItemViewTest : public ui::CocoaTest {
11 public:
12 StatusItemViewTest()
13 : view_([[MCStatusItemView alloc] init]) {
14 }
15
16 void SetUp() override {
17 ui::CocoaTest::SetUp();
18 [[test_window() contentView] addSubview:view_];
19 }
20
21 void TearDown() override {
22 [view_ removeItem];
23 ui::CocoaTest::TearDown();
24 }
25
26 protected:
27 base::scoped_nsobject<MCStatusItemView> view_;
28 };
29
30 // These tests are like TEST_VIEW() but set some of the properties.
31
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];
40
41 got_callback = NO;
42 [view_ rightMouseDown:nil];
43 EXPECT_TRUE(got_callback);
44 [view_ rightMouseUp:nil];
45
46 got_callback = NO;
47 [view_ otherMouseDown:nil];
48 EXPECT_TRUE(got_callback);
49 [view_ otherMouseUp:nil];
50 }
51
52 TEST_F(StatusItemViewTest, UnreadCount) {
53 CGFloat initial_width = NSWidth([view_ frame]);
54
55 [view_ setUnreadCount:2 withQuietMode:NO];
56 [view_ display];
57 EXPECT_EQ(NSWidth([view_ frame]), initial_width);
58
59 [view_ setUnreadCount:0 withQuietMode:NO];
60 [view_ display];
61 EXPECT_EQ(NSWidth([view_ frame]), initial_width);
62
63 [view_ setUnreadCount:1000 withQuietMode:YES];
64 [view_ display];
65 EXPECT_EQ(NSWidth([view_ frame]), initial_width);
66
67 [view_ setUnreadCount:0 withQuietMode:YES];
68 [view_ display];
69 EXPECT_EQ(NSWidth([view_ frame]), initial_width);
70 }
71
72 TEST_F(StatusItemViewTest, Highlight) {
73 [view_ setHighlight:YES];
74 [view_ display];
75 [view_ setHighlight:NO];
76 [view_ display];
77 }
78
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];
88 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698