| 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/memory/scoped_nsobject.h" | 7 #include "base/memory/scoped_nsobject.h" |
| 8 #include "base/utf_string_conversions.h" | 8 #include "base/utf_string_conversions.h" |
| 9 #import "ui/base/test/ui_cocoa_test_helper.h" | 9 #import "ui/base/test/ui_cocoa_test_helper.h" |
| 10 #include "ui/message_center/message_center.h" | 10 #include "ui/message_center/message_center.h" |
| (...skipping 24 matching lines...) Expand all Loading... |
| 35 | 35 |
| 36 TEST_F(TrayViewControllerTest, AddRemoveOne) { | 36 TEST_F(TrayViewControllerTest, AddRemoveOne) { |
| 37 NSScrollView* view = [[tray_ scrollView] documentView]; | 37 NSScrollView* view = [[tray_ scrollView] documentView]; |
| 38 EXPECT_EQ(0u, [[view subviews] count]); | 38 EXPECT_EQ(0u, [[view subviews] count]); |
| 39 center_->AddNotification(message_center::NOTIFICATION_TYPE_SIMPLE, | 39 center_->AddNotification(message_center::NOTIFICATION_TYPE_SIMPLE, |
| 40 "1", | 40 "1", |
| 41 ASCIIToUTF16("First notification"), | 41 ASCIIToUTF16("First notification"), |
| 42 ASCIIToUTF16("This is a simple test."), | 42 ASCIIToUTF16("This is a simple test."), |
| 43 string16(), | 43 string16(), |
| 44 std::string(), | 44 std::string(), |
| 45 NULL, |
| 45 NULL); | 46 NULL); |
| 46 [tray_ onMessageCenterTrayChanged]; | 47 [tray_ onMessageCenterTrayChanged]; |
| 47 ASSERT_EQ(1u, [[view subviews] count]); | 48 ASSERT_EQ(1u, [[view subviews] count]); |
| 48 | 49 |
| 49 // The view should have padding around it. | 50 // The view should have padding around it. |
| 50 NSView* notification = [[view subviews] objectAtIndex:0]; | 51 NSView* notification = [[view subviews] objectAtIndex:0]; |
| 51 NSRect notification_frame = [notification frame]; | 52 NSRect notification_frame = [notification frame]; |
| 52 EXPECT_CGFLOAT_EQ(2 * message_center::kMarginBetweenItems, | 53 EXPECT_CGFLOAT_EQ(2 * message_center::kMarginBetweenItems, |
| 53 NSHeight([view frame]) - NSHeight(notification_frame)); | 54 NSHeight([view frame]) - NSHeight(notification_frame)); |
| 54 EXPECT_CGFLOAT_EQ(2 * message_center::kMarginBetweenItems, | 55 EXPECT_CGFLOAT_EQ(2 * message_center::kMarginBetweenItems, |
| 55 NSWidth([view frame]) - NSWidth(notification_frame)); | 56 NSWidth([view frame]) - NSWidth(notification_frame)); |
| 56 EXPECT_GT(NSHeight([[tray_ view] frame]), | 57 EXPECT_GT(NSHeight([[tray_ view] frame]), |
| 57 NSHeight([[tray_ scrollView] frame])); | 58 NSHeight([[tray_ scrollView] frame])); |
| 58 | 59 |
| 59 center_->RemoveNotification("1", true); | 60 center_->RemoveNotification("1", true); |
| 60 [tray_ onMessageCenterTrayChanged]; | 61 [tray_ onMessageCenterTrayChanged]; |
| 61 EXPECT_EQ(0u, [[view subviews] count]); | 62 EXPECT_EQ(0u, [[view subviews] count]); |
| 62 EXPECT_CGFLOAT_EQ(0, NSHeight([view frame])); | 63 EXPECT_CGFLOAT_EQ(0, NSHeight([view frame])); |
| 63 } | 64 } |
| 64 | 65 |
| 65 TEST_F(TrayViewControllerTest, AddThreeClearAll) { | 66 TEST_F(TrayViewControllerTest, AddThreeClearAll) { |
| 66 NSScrollView* view = [[tray_ scrollView] documentView]; | 67 NSScrollView* view = [[tray_ scrollView] documentView]; |
| 67 EXPECT_EQ(0u, [[view subviews] count]); | 68 EXPECT_EQ(0u, [[view subviews] count]); |
| 68 center_->AddNotification(message_center::NOTIFICATION_TYPE_SIMPLE, | 69 center_->AddNotification(message_center::NOTIFICATION_TYPE_SIMPLE, |
| 69 "1", | 70 "1", |
| 70 ASCIIToUTF16("First notification"), | 71 ASCIIToUTF16("First notification"), |
| 71 ASCIIToUTF16("This is a simple test."), | 72 ASCIIToUTF16("This is a simple test."), |
| 72 string16(), | 73 string16(), |
| 73 std::string(), | 74 std::string(), |
| 75 NULL, |
| 74 NULL); | 76 NULL); |
| 75 center_->AddNotification(message_center::NOTIFICATION_TYPE_SIMPLE, | 77 center_->AddNotification(message_center::NOTIFICATION_TYPE_SIMPLE, |
| 76 "2", | 78 "2", |
| 77 ASCIIToUTF16("Second notification"), | 79 ASCIIToUTF16("Second notification"), |
| 78 ASCIIToUTF16("This is a simple test."), | 80 ASCIIToUTF16("This is a simple test."), |
| 79 string16(), | 81 string16(), |
| 80 std::string(), | 82 std::string(), |
| 83 NULL, |
| 81 NULL); | 84 NULL); |
| 82 center_->AddNotification(message_center::NOTIFICATION_TYPE_SIMPLE, | 85 center_->AddNotification(message_center::NOTIFICATION_TYPE_SIMPLE, |
| 83 "3", | 86 "3", |
| 84 ASCIIToUTF16("Third notification"), | 87 ASCIIToUTF16("Third notification"), |
| 85 ASCIIToUTF16("This is a simple test."), | 88 ASCIIToUTF16("This is a simple test."), |
| 86 string16(), | 89 string16(), |
| 87 std::string(), | 90 std::string(), |
| 91 NULL, |
| 88 NULL); | 92 NULL); |
| 89 [tray_ onMessageCenterTrayChanged]; | 93 [tray_ onMessageCenterTrayChanged]; |
| 90 ASSERT_EQ(3u, [[view subviews] count]); | 94 ASSERT_EQ(3u, [[view subviews] count]); |
| 91 | 95 |
| 92 [tray_ clearAllNotifications:nil]; | 96 [tray_ clearAllNotifications:nil]; |
| 93 [tray_ onMessageCenterTrayChanged]; | 97 [tray_ onMessageCenterTrayChanged]; |
| 94 | 98 |
| 95 EXPECT_EQ(0u, [[view subviews] count]); | 99 EXPECT_EQ(0u, [[view subviews] count]); |
| 96 EXPECT_CGFLOAT_EQ(0, NSHeight([view frame])); | 100 EXPECT_CGFLOAT_EQ(0, NSHeight([view frame])); |
| 97 } | 101 } |
| OLD | NEW |