| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 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 #include "ui/message_center/views/message_center_view.h" |
| 6 |
| 5 #include <map> | 7 #include <map> |
| 8 #include <utility> |
| 6 | 9 |
| 7 #include "base/logging.h" | 10 #include "base/logging.h" |
| 8 #include "base/memory/scoped_ptr.h" | 11 #include "base/memory/scoped_ptr.h" |
| 9 #include "base/strings/utf_string_conversions.h" | 12 #include "base/strings/utf_string_conversions.h" |
| 10 #include "testing/gtest/include/gtest/gtest.h" | 13 #include "testing/gtest/include/gtest/gtest.h" |
| 11 #include "ui/message_center/fake_message_center.h" | 14 #include "ui/message_center/fake_message_center.h" |
| 12 #include "ui/message_center/message_center_style.h" | 15 #include "ui/message_center/message_center_style.h" |
| 13 #include "ui/message_center/notification.h" | 16 #include "ui/message_center/notification.h" |
| 14 #include "ui/message_center/notification_list.h" | 17 #include "ui/message_center/notification_list.h" |
| 15 #include "ui/message_center/notification_types.h" | 18 #include "ui/message_center/notification_types.h" |
| 16 #include "ui/message_center/views/message_center_controller.h" | 19 #include "ui/message_center/views/message_center_controller.h" |
| 17 #include "ui/message_center/views/message_center_view.h" | |
| 18 #include "ui/message_center/views/message_list_view.h" | 20 #include "ui/message_center/views/message_list_view.h" |
| 19 #include "ui/message_center/views/notification_view.h" | 21 #include "ui/message_center/views/notification_view.h" |
| 20 | 22 |
| 21 namespace message_center { | 23 namespace message_center { |
| 22 | 24 |
| 23 static const char* kNotificationId1 = "notification id 1"; | 25 static const char* kNotificationId1 = "notification id 1"; |
| 24 static const char* kNotificationId2 = "notification id 2"; | 26 static const char* kNotificationId2 = "notification id 2"; |
| 25 | 27 |
| 26 /* Types **********************************************************************/ | 28 /* Types **********************************************************************/ |
| 27 | 29 |
| (...skipping 323 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 351 | 353 |
| 352 EXPECT_EQ( | 354 EXPECT_EQ( |
| 353 GetMessageListView()->height(), | 355 GetMessageListView()->height(), |
| 354 GetNotificationView(kNotificationId1)->GetHeightForWidth(width) + | 356 GetNotificationView(kNotificationId1)->GetHeightForWidth(width) + |
| 355 (kMarginBetweenItems - MessageView::GetShadowInsets().bottom()) + | 357 (kMarginBetweenItems - MessageView::GetShadowInsets().bottom()) + |
| 356 GetNotificationView(kNotificationId2)->GetHeightForWidth(width) + | 358 GetNotificationView(kNotificationId2)->GetHeightForWidth(width) + |
| 357 GetMessageListView()->GetInsets().height()); | 359 GetMessageListView()->GetInsets().height()); |
| 358 | 360 |
| 359 int previous_height = GetMessageListView()->height(); | 361 int previous_height = GetMessageListView()->height(); |
| 360 | 362 |
| 361 UpdateNotification(kNotificationId2, notification.Pass()); | 363 UpdateNotification(kNotificationId2, std::move(notification)); |
| 362 | 364 |
| 363 // Wait until the animation finishes if available. | 365 // Wait until the animation finishes if available. |
| 364 if (GetAnimator()->IsAnimating()) | 366 if (GetAnimator()->IsAnimating()) |
| 365 base::MessageLoop::current()->Run(); | 367 base::MessageLoop::current()->Run(); |
| 366 | 368 |
| 367 EXPECT_EQ(2, GetMessageListView()->child_count()); | 369 EXPECT_EQ(2, GetMessageListView()->child_count()); |
| 368 EXPECT_EQ(GetMessageListView()->height(), | 370 EXPECT_EQ(GetMessageListView()->height(), |
| 369 GetCalculatedMessageListViewHeight()); | 371 GetCalculatedMessageListViewHeight()); |
| 370 | 372 |
| 371 // The size must be changed, since the new string is longer than the old one. | 373 // The size must be changed, since the new string is longer than the old one. |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 409 GetMessageListView()->SetRepositionTargetForTest( | 411 GetMessageListView()->SetRepositionTargetForTest( |
| 410 GetNotificationView(kNotificationId1)->bounds()); | 412 GetNotificationView(kNotificationId1)->bounds()); |
| 411 | 413 |
| 412 scoped_ptr<Notification> notification(new Notification( | 414 scoped_ptr<Notification> notification(new Notification( |
| 413 NOTIFICATION_TYPE_SIMPLE, std::string(kNotificationId2), | 415 NOTIFICATION_TYPE_SIMPLE, std::string(kNotificationId2), |
| 414 base::UTF8ToUTF16("title2"), | 416 base::UTF8ToUTF16("title2"), |
| 415 base::UTF8ToUTF16("message\nwhich\nis\nvertically\nlong\n."), | 417 base::UTF8ToUTF16("message\nwhich\nis\nvertically\nlong\n."), |
| 416 gfx::Image(), base::UTF8ToUTF16("display source"), GURL(), | 418 gfx::Image(), base::UTF8ToUTF16("display source"), GURL(), |
| 417 NotifierId(NotifierId::APPLICATION, "extension_id"), | 419 NotifierId(NotifierId::APPLICATION, "extension_id"), |
| 418 message_center::RichNotificationData(), NULL)); | 420 message_center::RichNotificationData(), NULL)); |
| 419 UpdateNotification(kNotificationId2, notification.Pass()); | 421 UpdateNotification(kNotificationId2, std::move(notification)); |
| 420 | 422 |
| 421 // Wait until the animation finishes if available. | 423 // Wait until the animation finishes if available. |
| 422 if (GetAnimator()->IsAnimating()) | 424 if (GetAnimator()->IsAnimating()) |
| 423 base::MessageLoop::current()->Run(); | 425 base::MessageLoop::current()->Run(); |
| 424 | 426 |
| 425 // The vertical position of the target from bottom should be kept over change. | 427 // The vertical position of the target from bottom should be kept over change. |
| 426 int current_vertical_pos_from_bottom = | 428 int current_vertical_pos_from_bottom = |
| 427 GetMessageListView()->height() - | 429 GetMessageListView()->height() - |
| 428 GetNotificationView(kNotificationId1)->bounds().y(); | 430 GetNotificationView(kNotificationId1)->bounds().y(); |
| 429 EXPECT_EQ(previous_vertical_pos_from_bottom, | 431 EXPECT_EQ(previous_vertical_pos_from_bottom, |
| (...skipping 25 matching lines...) Expand all Loading... |
| 455 EXPECT_EQ(previous_notification2_y, | 457 EXPECT_EQ(previous_notification2_y, |
| 456 GetNotificationView(kNotificationId1)->bounds().y()); | 458 GetNotificationView(kNotificationId1)->bounds().y()); |
| 457 // The size should be kept. | 459 // The size should be kept. |
| 458 EXPECT_EQ(previous_height, GetMessageListView()->height()); | 460 EXPECT_EQ(previous_height, GetMessageListView()->height()); |
| 459 | 461 |
| 460 EXPECT_FALSE(GetNotificationView(kNotificationId2)); | 462 EXPECT_FALSE(GetNotificationView(kNotificationId2)); |
| 461 EXPECT_TRUE(GetNotificationView(kNotificationId1)); | 463 EXPECT_TRUE(GetNotificationView(kNotificationId1)); |
| 462 } | 464 } |
| 463 | 465 |
| 464 } // namespace message_center | 466 } // namespace message_center |
| OLD | NEW |