| 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 284 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 295 UTF8ToUTF16("First title"), UTF8ToUTF16("first message")); | 295 UTF8ToUTF16("First title"), UTF8ToUTF16("first message")); |
| 296 optional.items.push_back(item1); | 296 optional.items.push_back(item1); |
| 297 message_center::NotificationItem item2( | 297 message_center::NotificationItem item2( |
| 298 UTF8ToUTF16("Second title"), | 298 UTF8ToUTF16("Second title"), |
| 299 UTF8ToUTF16("second slightly longer message")); | 299 UTF8ToUTF16("second slightly longer message")); |
| 300 optional.items.push_back(item2); | 300 optional.items.push_back(item2); |
| 301 message_center::NotificationItem item3( | 301 message_center::NotificationItem item3( |
| 302 UTF8ToUTF16(""), // Test for empty string. | 302 UTF8ToUTF16(""), // Test for empty string. |
| 303 UTF8ToUTF16(" ")); // Test for string containing only spaces. | 303 UTF8ToUTF16(" ")); // Test for string containing only spaces. |
| 304 optional.items.push_back(item3); | 304 optional.items.push_back(item3); |
| 305 optional.context_message = UTF8ToUTF16("Context Message"); | 305 optional.context_message.message = "Context Message"; |
| 306 optional.context_message.is_origin = false; |
| 306 | 307 |
| 307 scoped_ptr<message_center::Notification> notification( | 308 scoped_ptr<message_center::Notification> notification( |
| 308 new message_center::Notification( | 309 new message_center::Notification( |
| 309 message_center::NOTIFICATION_TYPE_BASE_FORMAT, | 310 message_center::NOTIFICATION_TYPE_BASE_FORMAT, |
| 310 "an_id", | 311 "an_id", |
| 311 UTF8ToUTF16("Notification Title"), | 312 UTF8ToUTF16("Notification Title"), |
| 312 UTF8ToUTF16("Notification Message - should be hidden"), | 313 UTF8ToUTF16("Notification Message - should be hidden"), |
| 313 gfx::Image(), | 314 gfx::Image(), |
| 314 base::string16(), | 315 base::string16(), |
| 315 DummyNotifierId(), | 316 DummyNotifierId(), |
| (...skipping 10 matching lines...) Expand all Loading... |
| 326 EXPECT_TRUE([[controller messageView] isHidden]); | 327 EXPECT_TRUE([[controller messageView] isHidden]); |
| 327 EXPECT_FALSE([[controller contextMessageView] isHidden]); | 328 EXPECT_FALSE([[controller contextMessageView] isHidden]); |
| 328 | 329 |
| 329 EXPECT_EQ(3u, [[[controller listView] subviews] count]); | 330 EXPECT_EQ(3u, [[[controller listView] subviews] count]); |
| 330 EXPECT_LT(NSMaxY([[controller listView] frame]), | 331 EXPECT_LT(NSMaxY([[controller listView] frame]), |
| 331 NSMinY([[controller titleView] frame])); | 332 NSMinY([[controller titleView] frame])); |
| 332 } | 333 } |
| 333 | 334 |
| 334 TEST_F(NotificationControllerTest, NoMessage) { | 335 TEST_F(NotificationControllerTest, NoMessage) { |
| 335 message_center::RichNotificationData optional; | 336 message_center::RichNotificationData optional; |
| 336 optional.context_message = UTF8ToUTF16("Context Message"); | 337 optional.context_message.message = "Context Message"; |
| 338 optional.context_message.is_origin = false; |
| 337 | 339 |
| 338 scoped_ptr<message_center::Notification> notification( | 340 scoped_ptr<message_center::Notification> notification( |
| 339 new message_center::Notification( | 341 new message_center::Notification( |
| 340 message_center::NOTIFICATION_TYPE_BASE_FORMAT, | 342 message_center::NOTIFICATION_TYPE_BASE_FORMAT, |
| 341 "an_id", | 343 "an_id", |
| 342 UTF8ToUTF16("Notification Title"), | 344 UTF8ToUTF16("Notification Title"), |
| 343 UTF8ToUTF16(""), | 345 UTF8ToUTF16(""), |
| 344 gfx::Image(), | 346 gfx::Image(), |
| 345 base::string16(), | 347 base::string16(), |
| 346 DummyNotifierId(), | 348 DummyNotifierId(), |
| (...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 415 notification->set_title(ASCIIToUTF16("one line")); | 417 notification->set_title(ASCIIToUTF16("one line")); |
| 416 [controller updateNotification:notification.get()]; | 418 [controller updateNotification:notification.get()]; |
| 417 EXPECT_EQ(2u, compute_message_lines()); | 419 EXPECT_EQ(2u, compute_message_lines()); |
| 418 | 420 |
| 419 // Message, image and two line title: 1 lines. | 421 // Message, image and two line title: 1 lines. |
| 420 notification->set_title(ASCIIToUTF16("two\nlines")); | 422 notification->set_title(ASCIIToUTF16("two\nlines")); |
| 421 [controller updateNotification:notification.get()]; | 423 [controller updateNotification:notification.get()]; |
| 422 EXPECT_EQ(1u, compute_message_lines()); | 424 EXPECT_EQ(1u, compute_message_lines()); |
| 423 | 425 |
| 424 // Same as above, but context message takes away from message lines. | 426 // Same as above, but context message takes away from message lines. |
| 425 notification->set_context_message(base::UTF8ToUTF16("foo")); | 427 notification->set_context_message("foo", false); |
| 426 notification->set_title(ASCIIToUTF16("")); | 428 notification->set_title(ASCIIToUTF16("")); |
| 427 [controller updateNotification:notification.get()]; | 429 [controller updateNotification:notification.get()]; |
| 428 EXPECT_EQ(1u, compute_message_lines()); | 430 EXPECT_EQ(1u, compute_message_lines()); |
| 429 | 431 |
| 430 notification->set_title(ASCIIToUTF16("one line")); | 432 notification->set_title(ASCIIToUTF16("one line")); |
| 431 [controller updateNotification:notification.get()]; | 433 [controller updateNotification:notification.get()]; |
| 432 EXPECT_EQ(1u, compute_message_lines()); | 434 EXPECT_EQ(1u, compute_message_lines()); |
| 433 | 435 |
| 434 notification->set_title(ASCIIToUTF16("two\nlines")); | 436 notification->set_title(ASCIIToUTF16("two\nlines")); |
| 435 [controller updateNotification:notification.get()]; | 437 [controller updateNotification:notification.get()]; |
| 436 EXPECT_EQ(0u, compute_message_lines()); | 438 EXPECT_EQ(0u, compute_message_lines()); |
| 437 } | 439 } |
| 438 | 440 |
| 439 } // namespace message_center | 441 } // namespace message_center |
| OLD | NEW |