| 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/notification_controller.h" | 5 #import "ui/message_center/cocoa/notification_controller.h" |
| 6 | 6 |
| 7 #include "base/mac/foundation_util.h" | 7 #include "base/mac/foundation_util.h" |
| 8 #include "base/mac/scoped_nsobject.h" | 8 #include "base/mac/scoped_nsobject.h" |
| 9 #include "base/memory/scoped_ptr.h" | 9 #include "base/memory/scoped_ptr.h" |
| 10 #include "base/strings/sys_string_conversions.h" | 10 #include "base/strings/sys_string_conversions.h" |
| (...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 77 } | 77 } |
| 78 | 78 |
| 79 - (NSTextField*)titleView { | 79 - (NSTextField*)titleView { |
| 80 return title_.get(); | 80 return title_.get(); |
| 81 } | 81 } |
| 82 | 82 |
| 83 - (NSTextField*)messageView { | 83 - (NSTextField*)messageView { |
| 84 return message_.get(); | 84 return message_.get(); |
| 85 } | 85 } |
| 86 | 86 |
| 87 - (NSTextField*)contextMessageView { | |
| 88 return contextMessage_.get(); | |
| 89 } | |
| 90 | |
| 91 - (NSView*)listItemView { | 87 - (NSView*)listItemView { |
| 92 return listItemView_.get(); | 88 return listItemView_.get(); |
| 93 } | 89 } |
| 94 @end | 90 @end |
| 95 | 91 |
| 96 class NotificationControllerTest : public ui::CocoaTest { | 92 class NotificationControllerTest : public ui::CocoaTest { |
| 97 public: | 93 public: |
| 98 NSImage* TestIcon() { | 94 NSImage* TestIcon() { |
| 99 return [NSImage imageNamed:NSImageNameUser]; | 95 return [NSImage imageNamed:NSImageNameUser]; |
| 100 } | 96 } |
| (...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 269 | 265 |
| 270 TEST_F(NotificationControllerTest, List) { | 266 TEST_F(NotificationControllerTest, List) { |
| 271 message_center::RichNotificationData optional; | 267 message_center::RichNotificationData optional; |
| 272 message_center::NotificationItem item1( | 268 message_center::NotificationItem item1( |
| 273 UTF8ToUTF16("First title"), UTF8ToUTF16("first message")); | 269 UTF8ToUTF16("First title"), UTF8ToUTF16("first message")); |
| 274 optional.items.push_back(item1); | 270 optional.items.push_back(item1); |
| 275 message_center::NotificationItem item2( | 271 message_center::NotificationItem item2( |
| 276 UTF8ToUTF16("Second title"), | 272 UTF8ToUTF16("Second title"), |
| 277 UTF8ToUTF16("second slightly longer message")); | 273 UTF8ToUTF16("second slightly longer message")); |
| 278 optional.items.push_back(item2); | 274 optional.items.push_back(item2); |
| 279 optional.context_message = UTF8ToUTF16("Context Message"); | |
| 280 | 275 |
| 281 scoped_ptr<message_center::Notification> notification( | 276 scoped_ptr<message_center::Notification> notification( |
| 282 new message_center::Notification( | 277 new message_center::Notification( |
| 283 message_center::NOTIFICATION_TYPE_BASE_FORMAT, | 278 message_center::NOTIFICATION_TYPE_BASE_FORMAT, |
| 284 "an_id", | 279 "an_id", |
| 285 UTF8ToUTF16("Notification Title"), | 280 UTF8ToUTF16("Notification Title"), |
| 286 UTF8ToUTF16("Notification Message - should be hidden"), | 281 UTF8ToUTF16("Notification Message - should be hidden"), |
| 287 gfx::Image(), | 282 gfx::Image(), |
| 288 string16(), | 283 string16(), |
| 289 message_center::NotifierId(), | 284 message_center::NotifierId(), |
| 290 optional, | 285 optional, |
| 291 NULL)); | 286 NULL)); |
| 292 | 287 |
| 293 MockMessageCenter message_center; | 288 MockMessageCenter message_center; |
| 294 base::scoped_nsobject<MCNotificationController> controller( | 289 base::scoped_nsobject<MCNotificationController> controller( |
| 295 [[MCNotificationController alloc] initWithNotification:notification.get() | 290 [[MCNotificationController alloc] initWithNotification:notification.get() |
| 296 messageCenter:&message_center]); | 291 messageCenter:&message_center]); |
| 297 [controller view]; | 292 [controller view]; |
| 298 | 293 |
| 299 EXPECT_FALSE([[controller titleView] isHidden]); | 294 EXPECT_FALSE([[controller titleView] isHidden]); |
| 300 EXPECT_TRUE([[controller messageView] isHidden]); | 295 EXPECT_TRUE([[controller messageView] isHidden]); |
| 301 EXPECT_FALSE([[controller contextMessageView] isHidden]); | |
| 302 | 296 |
| 303 EXPECT_EQ(2u, [[[controller listItemView] subviews] count]); | 297 EXPECT_EQ(2u, [[[controller listItemView] subviews] count]); |
| 304 EXPECT_LT(NSMaxY([[controller listItemView] frame]), | 298 EXPECT_LT(NSMaxY([[controller listItemView] frame]), |
| 305 NSMinY([[controller titleView] frame])); | 299 NSMinY([[controller titleView] frame])); |
| 306 } | 300 } |
| OLD | NEW |