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/tray_view_controller.h" | 5 #import "ui/message_center/cocoa/tray_view_controller.h" |
6 | 6 |
7 #include "base/mac/scoped_nsobject.h" | 7 #include "base/mac/scoped_nsobject.h" |
8 #include "base/message_loop/message_loop.h" | 8 #include "base/message_loop/message_loop.h" |
9 #include "base/run_loop.h" | 9 #include "base/run_loop.h" |
10 #include "base/strings/utf_string_conversions.h" | 10 #include "base/strings/utf_string_conversions.h" |
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
69 TEST_F(TrayViewControllerTest, AddRemoveOne) { | 69 TEST_F(TrayViewControllerTest, AddRemoveOne) { |
70 NSScrollView* view = [[tray_ scrollView] documentView]; | 70 NSScrollView* view = [[tray_ scrollView] documentView]; |
71 EXPECT_EQ(0u, [[view subviews] count]); | 71 EXPECT_EQ(0u, [[view subviews] count]); |
72 scoped_ptr<message_center::Notification> notification_data; | 72 scoped_ptr<message_center::Notification> notification_data; |
73 notification_data.reset(new message_center::Notification( | 73 notification_data.reset(new message_center::Notification( |
74 message_center::NOTIFICATION_TYPE_SIMPLE, | 74 message_center::NOTIFICATION_TYPE_SIMPLE, |
75 "1", | 75 "1", |
76 ASCIIToUTF16("First notification"), | 76 ASCIIToUTF16("First notification"), |
77 ASCIIToUTF16("This is a simple test."), | 77 ASCIIToUTF16("This is a simple test."), |
78 gfx::Image(), | 78 gfx::Image(), |
79 string16(), | 79 base::string16(), |
80 DummyNotifierId(), | 80 DummyNotifierId(), |
81 message_center::RichNotificationData(), | 81 message_center::RichNotificationData(), |
82 NULL)); | 82 NULL)); |
83 center_->AddNotification(notification_data.Pass()); | 83 center_->AddNotification(notification_data.Pass()); |
84 [tray_ onMessageCenterTrayChanged]; | 84 [tray_ onMessageCenterTrayChanged]; |
85 ASSERT_EQ(1u, [[view subviews] count]); | 85 ASSERT_EQ(1u, [[view subviews] count]); |
86 | 86 |
87 // The view should have padding around it. | 87 // The view should have padding around it. |
88 NSView* notification = [[view subviews] objectAtIndex:0]; | 88 NSView* notification = [[view subviews] objectAtIndex:0]; |
89 NSRect notification_frame = [notification frame]; | 89 NSRect notification_frame = [notification frame]; |
(...skipping 13 matching lines...) Expand all Loading... |
103 TEST_F(TrayViewControllerTest, AddThreeClearAll) { | 103 TEST_F(TrayViewControllerTest, AddThreeClearAll) { |
104 NSScrollView* view = [[tray_ scrollView] documentView]; | 104 NSScrollView* view = [[tray_ scrollView] documentView]; |
105 EXPECT_EQ(0u, [[view subviews] count]); | 105 EXPECT_EQ(0u, [[view subviews] count]); |
106 scoped_ptr<message_center::Notification> notification; | 106 scoped_ptr<message_center::Notification> notification; |
107 notification.reset(new message_center::Notification( | 107 notification.reset(new message_center::Notification( |
108 message_center::NOTIFICATION_TYPE_SIMPLE, | 108 message_center::NOTIFICATION_TYPE_SIMPLE, |
109 "1", | 109 "1", |
110 ASCIIToUTF16("First notification"), | 110 ASCIIToUTF16("First notification"), |
111 ASCIIToUTF16("This is a simple test."), | 111 ASCIIToUTF16("This is a simple test."), |
112 gfx::Image(), | 112 gfx::Image(), |
113 string16(), | 113 base::string16(), |
114 DummyNotifierId(), | 114 DummyNotifierId(), |
115 message_center::RichNotificationData(), | 115 message_center::RichNotificationData(), |
116 NULL)); | 116 NULL)); |
117 center_->AddNotification(notification.Pass()); | 117 center_->AddNotification(notification.Pass()); |
118 notification.reset(new message_center::Notification( | 118 notification.reset(new message_center::Notification( |
119 message_center::NOTIFICATION_TYPE_SIMPLE, | 119 message_center::NOTIFICATION_TYPE_SIMPLE, |
120 "2", | 120 "2", |
121 ASCIIToUTF16("Second notification"), | 121 ASCIIToUTF16("Second notification"), |
122 ASCIIToUTF16("This is a simple test."), | 122 ASCIIToUTF16("This is a simple test."), |
123 gfx::Image(), | 123 gfx::Image(), |
124 string16(), | 124 base::string16(), |
125 DummyNotifierId(), | 125 DummyNotifierId(), |
126 message_center::RichNotificationData(), | 126 message_center::RichNotificationData(), |
127 NULL)); | 127 NULL)); |
128 center_->AddNotification(notification.Pass()); | 128 center_->AddNotification(notification.Pass()); |
129 notification.reset(new message_center::Notification( | 129 notification.reset(new message_center::Notification( |
130 message_center::NOTIFICATION_TYPE_SIMPLE, | 130 message_center::NOTIFICATION_TYPE_SIMPLE, |
131 "3", | 131 "3", |
132 ASCIIToUTF16("Third notification"), | 132 ASCIIToUTF16("Third notification"), |
133 ASCIIToUTF16("This is a simple test."), | 133 ASCIIToUTF16("This is a simple test."), |
134 gfx::Image(), | 134 gfx::Image(), |
135 string16(), | 135 base::string16(), |
136 DummyNotifierId(), | 136 DummyNotifierId(), |
137 message_center::RichNotificationData(), | 137 message_center::RichNotificationData(), |
138 NULL)); | 138 NULL)); |
139 center_->AddNotification(notification.Pass()); | 139 center_->AddNotification(notification.Pass()); |
140 [tray_ onMessageCenterTrayChanged]; | 140 [tray_ onMessageCenterTrayChanged]; |
141 ASSERT_EQ(3u, [[view subviews] count]); | 141 ASSERT_EQ(3u, [[view subviews] count]); |
142 | 142 |
143 [tray_ clearAllNotifications:nil]; | 143 [tray_ clearAllNotifications:nil]; |
144 WaitForAnimationEnded(); | 144 WaitForAnimationEnded(); |
145 [tray_ onMessageCenterTrayChanged]; | 145 [tray_ onMessageCenterTrayChanged]; |
(...skipping 12 matching lines...) Expand all Loading... |
158 NSMinX([[tray_ pauseButton] frame])); | 158 NSMinX([[tray_ pauseButton] frame])); |
159 | 159 |
160 // Add a notification. | 160 // Add a notification. |
161 scoped_ptr<message_center::Notification> notification; | 161 scoped_ptr<message_center::Notification> notification; |
162 notification.reset(new message_center::Notification( | 162 notification.reset(new message_center::Notification( |
163 message_center::NOTIFICATION_TYPE_SIMPLE, | 163 message_center::NOTIFICATION_TYPE_SIMPLE, |
164 "1", | 164 "1", |
165 ASCIIToUTF16("First notification"), | 165 ASCIIToUTF16("First notification"), |
166 ASCIIToUTF16("This is a simple test."), | 166 ASCIIToUTF16("This is a simple test."), |
167 gfx::Image(), | 167 gfx::Image(), |
168 string16(), | 168 base::string16(), |
169 DummyNotifierId(), | 169 DummyNotifierId(), |
170 message_center::RichNotificationData(), | 170 message_center::RichNotificationData(), |
171 NULL)); | 171 NULL)); |
172 center_->AddNotification(notification.Pass()); | 172 center_->AddNotification(notification.Pass()); |
173 [tray_ onMessageCenterTrayChanged]; | 173 [tray_ onMessageCenterTrayChanged]; |
174 | 174 |
175 // Clear all should now be visible. | 175 // Clear all should now be visible. |
176 EXPECT_FALSE([[tray_ clearAllButton] isHidden]); | 176 EXPECT_FALSE([[tray_ clearAllButton] isHidden]); |
177 EXPECT_GT(NSMinX([[tray_ clearAllButton] frame]), | 177 EXPECT_GT(NSMinX([[tray_ clearAllButton] frame]), |
178 NSMinX([[tray_ pauseButton] frame])); | 178 NSMinX([[tray_ pauseButton] frame])); |
179 | 179 |
180 // Adding a second notification should keep things still visible. | 180 // Adding a second notification should keep things still visible. |
181 notification.reset(new message_center::Notification( | 181 notification.reset(new message_center::Notification( |
182 message_center::NOTIFICATION_TYPE_SIMPLE, | 182 message_center::NOTIFICATION_TYPE_SIMPLE, |
183 "2", | 183 "2", |
184 ASCIIToUTF16("Second notification"), | 184 ASCIIToUTF16("Second notification"), |
185 ASCIIToUTF16("This is a simple test."), | 185 ASCIIToUTF16("This is a simple test."), |
186 gfx::Image(), | 186 gfx::Image(), |
187 string16(), | 187 base::string16(), |
188 DummyNotifierId(), | 188 DummyNotifierId(), |
189 message_center::RichNotificationData(), | 189 message_center::RichNotificationData(), |
190 NULL)); | 190 NULL)); |
191 center_->AddNotification(notification.Pass()); | 191 center_->AddNotification(notification.Pass()); |
192 [tray_ onMessageCenterTrayChanged]; | 192 [tray_ onMessageCenterTrayChanged]; |
193 EXPECT_FALSE([[tray_ clearAllButton] isHidden]); | 193 EXPECT_FALSE([[tray_ clearAllButton] isHidden]); |
194 EXPECT_GT(NSMinX([[tray_ clearAllButton] frame]), | 194 EXPECT_GT(NSMinX([[tray_ clearAllButton] frame]), |
195 NSMinX([[tray_ pauseButton] frame])); | 195 NSMinX([[tray_ pauseButton] frame])); |
196 | 196 |
197 // Clear all notifications. | 197 // Clear all notifications. |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
237 | 237 |
238 [tray_ showMessages:nil]; | 238 [tray_ showMessages:nil]; |
239 EXPECT_EQ(1, provider.closed_called_count()); | 239 EXPECT_EQ(1, provider.closed_called_count()); |
240 EXPECT_TRUE(center_->IsMessageCenterVisible()); | 240 EXPECT_TRUE(center_->IsMessageCenterVisible()); |
241 | 241 |
242 // The tray should be back at its previous height now. | 242 // The tray should be back at its previous height now. |
243 EXPECT_EQ(trayHeight, NSHeight([[tray_ view] frame])); | 243 EXPECT_EQ(trayHeight, NSHeight([[tray_ view] frame])); |
244 } | 244 } |
245 | 245 |
246 } // namespace message_center | 246 } // namespace message_center |
OLD | NEW |