| 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 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 91 EXPECT_CGFLOAT_EQ(2 * message_center::kMarginBetweenItems, | 91 EXPECT_CGFLOAT_EQ(2 * message_center::kMarginBetweenItems, |
| 92 NSHeight([view frame]) - NSHeight(notification_frame)); | 92 NSHeight([view frame]) - NSHeight(notification_frame)); |
| 93 EXPECT_CGFLOAT_EQ(2 * message_center::kMarginBetweenItems, | 93 EXPECT_CGFLOAT_EQ(2 * message_center::kMarginBetweenItems, |
| 94 NSWidth([view frame]) - NSWidth(notification_frame)); | 94 NSWidth([view frame]) - NSWidth(notification_frame)); |
| 95 EXPECT_GT(NSHeight([[tray_ view] frame]), | 95 EXPECT_GT(NSHeight([[tray_ view] frame]), |
| 96 NSHeight([[tray_ scrollView] frame])); | 96 NSHeight([[tray_ scrollView] frame])); |
| 97 | 97 |
| 98 center_->RemoveNotification("1", true); | 98 center_->RemoveNotification("1", true); |
| 99 [tray_ onMessageCenterTrayChanged]; | 99 [tray_ onMessageCenterTrayChanged]; |
| 100 EXPECT_EQ(0u, [[view subviews] count]); | 100 EXPECT_EQ(0u, [[view subviews] count]); |
| 101 EXPECT_CGFLOAT_EQ(0, NSHeight([view frame])); | 101 // The empty tray is now 100px tall to accommodate |
| 102 // the empty message. |
| 103 EXPECT_CGFLOAT_EQ(message_center::kMinScrollViewHeight, |
| 104 NSHeight([view frame])); |
| 102 } | 105 } |
| 103 | 106 |
| 104 TEST_F(TrayViewControllerTest, AddThreeClearAll) { | 107 TEST_F(TrayViewControllerTest, AddThreeClearAll) { |
| 105 NSScrollView* view = [[tray_ scrollView] documentView]; | 108 NSScrollView* view = [[tray_ scrollView] documentView]; |
| 106 EXPECT_EQ(0u, [[view subviews] count]); | 109 EXPECT_EQ(0u, [[view subviews] count]); |
| 107 scoped_ptr<message_center::Notification> notification; | 110 scoped_ptr<message_center::Notification> notification; |
| 108 notification.reset(new message_center::Notification( | 111 notification.reset(new message_center::Notification( |
| 109 message_center::NOTIFICATION_TYPE_SIMPLE, | 112 message_center::NOTIFICATION_TYPE_SIMPLE, |
| 110 "1", | 113 "1", |
| 111 ASCIIToUTF16("First notification"), | 114 ASCIIToUTF16("First notification"), |
| (...skipping 27 matching lines...) Expand all Loading... |
| 139 NULL)); | 142 NULL)); |
| 140 center_->AddNotification(notification.Pass()); | 143 center_->AddNotification(notification.Pass()); |
| 141 [tray_ onMessageCenterTrayChanged]; | 144 [tray_ onMessageCenterTrayChanged]; |
| 142 ASSERT_EQ(3u, [[view subviews] count]); | 145 ASSERT_EQ(3u, [[view subviews] count]); |
| 143 | 146 |
| 144 [tray_ clearAllNotifications:nil]; | 147 [tray_ clearAllNotifications:nil]; |
| 145 WaitForAnimationEnded(); | 148 WaitForAnimationEnded(); |
| 146 [tray_ onMessageCenterTrayChanged]; | 149 [tray_ onMessageCenterTrayChanged]; |
| 147 | 150 |
| 148 EXPECT_EQ(0u, [[view subviews] count]); | 151 EXPECT_EQ(0u, [[view subviews] count]); |
| 149 EXPECT_CGFLOAT_EQ(0, NSHeight([view frame])); | 152 // The empty tray is now 100px tall to accommodate |
| 153 // the empty message. |
| 154 EXPECT_CGFLOAT_EQ(message_center::kMinScrollViewHeight, |
| 155 NSHeight([view frame])); |
| 150 } | 156 } |
| 151 | 157 |
| 152 TEST_F(TrayViewControllerTest, NoClearAllWhenNoNotifications) { | 158 TEST_F(TrayViewControllerTest, NoClearAllWhenNoNotifications) { |
| 153 EXPECT_TRUE([tray_ pauseButton]); | 159 EXPECT_TRUE([tray_ pauseButton]); |
| 154 EXPECT_TRUE([tray_ clearAllButton]); | 160 EXPECT_TRUE([tray_ clearAllButton]); |
| 155 | 161 |
| 156 // With no notifications, the clear all button should be hidden. | 162 // With no notifications, the clear all button should be hidden. |
| 157 EXPECT_TRUE([[tray_ clearAllButton] isHidden]); | 163 EXPECT_TRUE([[tray_ clearAllButton] isHidden]); |
| 158 EXPECT_LT(NSMinX([[tray_ clearAllButton] frame]), | 164 EXPECT_LT(NSMinX([[tray_ clearAllButton] frame]), |
| 159 NSMinX([[tray_ pauseButton] frame])); | 165 NSMinX([[tray_ pauseButton] frame])); |
| (...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 237 EXPECT_LT(trayHeight, NSHeight([[tray_ view] frame])); | 243 EXPECT_LT(trayHeight, NSHeight([[tray_ view] frame])); |
| 238 | 244 |
| 239 [tray_ showMessages:nil]; | 245 [tray_ showMessages:nil]; |
| 240 EXPECT_EQ(1, provider.closed_called_count()); | 246 EXPECT_EQ(1, provider.closed_called_count()); |
| 241 EXPECT_TRUE(center_->IsMessageCenterVisible()); | 247 EXPECT_TRUE(center_->IsMessageCenterVisible()); |
| 242 | 248 |
| 243 // The tray should be back at its previous height now. | 249 // The tray should be back at its previous height now. |
| 244 EXPECT_EQ(trayHeight, NSHeight([[tray_ view] frame])); | 250 EXPECT_EQ(trayHeight, NSHeight([[tray_ view] frame])); |
| 245 } | 251 } |
| 246 | 252 |
| 253 TEST_F(TrayViewControllerTest, EmptyCenter) { |
| 254 EXPECT_FALSE([[tray_ emptyDescription] isHidden]); |
| 255 |
| 256 // With no notifications, the divider should be hidden. |
| 257 EXPECT_TRUE([[tray_ divider] isHidden]); |
| 258 EXPECT_TRUE([[tray_ scrollView] isHidden]); |
| 259 |
| 260 scoped_ptr<message_center::Notification> notification; |
| 261 notification.reset(new message_center::Notification( |
| 262 message_center::NOTIFICATION_TYPE_SIMPLE, |
| 263 "1", |
| 264 ASCIIToUTF16("First notification"), |
| 265 ASCIIToUTF16("This is a simple test."), |
| 266 gfx::Image(), |
| 267 base::string16(), |
| 268 DummyNotifierId(), |
| 269 message_center::RichNotificationData(), |
| 270 NULL)); |
| 271 center_->AddNotification(notification.Pass()); |
| 272 [tray_ onMessageCenterTrayChanged]; |
| 273 |
| 274 EXPECT_FALSE([[tray_ divider] isHidden]); |
| 275 EXPECT_FALSE([[tray_ scrollView] isHidden]); |
| 276 EXPECT_TRUE([[tray_ emptyDescription] isHidden]); |
| 277 } |
| 278 |
| 247 } // namespace message_center | 279 } // namespace message_center |
| OLD | NEW |