| 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 "chrome/browser/ui/views/message_center/web_notification_tray.h" | 5 #include "chrome/browser/ui/views/message_center/web_notification_tray.h" |
| 6 | 6 |
| 7 #include <set> | 7 #include <set> |
| 8 | 8 |
| 9 #include "ash/root_window_controller.h" | 9 #include "ash/root_window_controller.h" |
| 10 #include "ash/system/status_area_widget.h" | 10 #include "ash/system/status_area_widget.h" |
| (...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 129 EXPECT_FALSE(message_center->HasNotification("test_id1")); | 129 EXPECT_FALSE(message_center->HasNotification("test_id1")); |
| 130 EXPECT_EQ(1u, message_center->NotificationCount()); | 130 EXPECT_EQ(1u, message_center->NotificationCount()); |
| 131 | 131 |
| 132 // Remove the remaining notification. | 132 // Remove the remaining notification. |
| 133 RemoveNotification("test_id3"); | 133 RemoveNotification("test_id3"); |
| 134 EXPECT_EQ(0u, message_center->NotificationCount()); | 134 EXPECT_EQ(0u, message_center->NotificationCount()); |
| 135 EXPECT_FALSE(message_center->HasNotification("test_id3")); | 135 EXPECT_FALSE(message_center->HasNotification("test_id3")); |
| 136 } | 136 } |
| 137 | 137 |
| 138 IN_PROC_BROWSER_TEST_F(WebNotificationTrayTest, WebNotificationPopupBubble) { | 138 IN_PROC_BROWSER_TEST_F(WebNotificationTrayTest, WebNotificationPopupBubble) { |
| 139 scoped_ptr<WebNotificationTray> tray(new WebNotificationTray()); | 139 scoped_ptr<WebNotificationTray> tray(new WebNotificationTray(NULL)); |
| 140 tray->message_center(); | 140 tray->message_center(); |
| 141 | 141 |
| 142 // Adding a notification should show the popup bubble. | 142 // Adding a notification should show the popup bubble. |
| 143 AddNotification("test_id1", "replace_id1"); | 143 AddNotification("test_id1", "replace_id1"); |
| 144 EXPECT_TRUE(tray->message_center_tray_->popups_visible()); | 144 EXPECT_TRUE(tray->message_center_tray_->popups_visible()); |
| 145 | 145 |
| 146 // Updating a notification should not hide the popup bubble. | 146 // Updating a notification should not hide the popup bubble. |
| 147 AddNotification("test_id2", "replace_id2"); | 147 AddNotification("test_id2", "replace_id2"); |
| 148 UpdateNotification("replace_id2", "test_id3"); | 148 UpdateNotification("replace_id2", "test_id3"); |
| 149 EXPECT_TRUE(tray->message_center_tray_->popups_visible()); | 149 EXPECT_TRUE(tray->message_center_tray_->popups_visible()); |
| 150 | 150 |
| 151 // Removing the first notification should not hide the popup bubble. | 151 // Removing the first notification should not hide the popup bubble. |
| 152 RemoveNotification("test_id1"); | 152 RemoveNotification("test_id1"); |
| 153 EXPECT_TRUE(tray->message_center_tray_->popups_visible()); | 153 EXPECT_TRUE(tray->message_center_tray_->popups_visible()); |
| 154 | 154 |
| 155 // Removing the visible notification should hide the popup bubble. | 155 // Removing the visible notification should hide the popup bubble. |
| 156 RemoveNotification("test_id3"); | 156 RemoveNotification("test_id3"); |
| 157 EXPECT_FALSE(tray->message_center_tray_->popups_visible()); | 157 EXPECT_FALSE(tray->message_center_tray_->popups_visible()); |
| 158 } | 158 } |
| 159 | 159 |
| 160 using message_center::NotificationList; | 160 using message_center::NotificationList; |
| 161 | 161 |
| 162 // Flaky, see http://crbug.com/222500 . | 162 // Flaky, see http://crbug.com/222500 . |
| 163 IN_PROC_BROWSER_TEST_F(WebNotificationTrayTest, | 163 IN_PROC_BROWSER_TEST_F(WebNotificationTrayTest, |
| 164 DISABLED_ManyMessageCenterNotifications) { | 164 DISABLED_ManyMessageCenterNotifications) { |
| 165 scoped_ptr<WebNotificationTray> tray(new WebNotificationTray()); | 165 scoped_ptr<WebNotificationTray> tray(new WebNotificationTray(NULL)); |
| 166 message_center::MessageCenter* message_center = tray->message_center(); | 166 message_center::MessageCenter* message_center = tray->message_center(); |
| 167 | 167 |
| 168 // Add the max visible notifications +1, ensure the correct visible number. | 168 // Add the max visible notifications +1, ensure the correct visible number. |
| 169 size_t notifications_to_add = kMaxVisibleMessageCenterNotifications + 1; | 169 size_t notifications_to_add = kMaxVisibleMessageCenterNotifications + 1; |
| 170 for (size_t i = 0; i < notifications_to_add; ++i) { | 170 for (size_t i = 0; i < notifications_to_add; ++i) { |
| 171 std::string id = base::StringPrintf("test_id%d", static_cast<int>(i)); | 171 std::string id = base::StringPrintf("test_id%d", static_cast<int>(i)); |
| 172 std::string replace_id = | 172 std::string replace_id = |
| 173 base::StringPrintf("replace_id%d", static_cast<int>(i)); | 173 base::StringPrintf("replace_id%d", static_cast<int>(i)); |
| 174 AddNotification(id, replace_id); | 174 AddNotification(id, replace_id); |
| 175 } | 175 } |
| 176 bool shown = tray->message_center_tray_->ShowMessageCenterBubble(); | 176 bool shown = tray->message_center_tray_->ShowMessageCenterBubble(); |
| 177 EXPECT_TRUE(shown); | 177 EXPECT_TRUE(shown); |
| 178 content::RunAllPendingInMessageLoop(); | 178 content::RunAllPendingInMessageLoop(); |
| 179 EXPECT_TRUE(tray->message_center_delegate_ != NULL); | 179 EXPECT_TRUE(tray->message_center_delegate_ != NULL); |
| 180 EXPECT_EQ(notifications_to_add, message_center->NotificationCount()); | 180 EXPECT_EQ(notifications_to_add, message_center->NotificationCount()); |
| 181 EXPECT_EQ(kMaxVisibleMessageCenterNotifications, | 181 EXPECT_EQ(kMaxVisibleMessageCenterNotifications, |
| 182 tray->message_center_delegate_->NumMessageViewsForTest()); | 182 tray->message_center_delegate_->NumMessageViewsForTest()); |
| 183 } | 183 } |
| 184 | 184 |
| 185 IN_PROC_BROWSER_TEST_F(WebNotificationTrayTest, ManyPopupNotifications) { | 185 IN_PROC_BROWSER_TEST_F(WebNotificationTrayTest, ManyPopupNotifications) { |
| 186 scoped_ptr<WebNotificationTray> tray(new WebNotificationTray()); | 186 scoped_ptr<WebNotificationTray> tray(new WebNotificationTray(NULL)); |
| 187 message_center::MessageCenter* message_center = tray->message_center(); | 187 message_center::MessageCenter* message_center = tray->message_center(); |
| 188 | 188 |
| 189 // Add the max visible popup notifications +1, ensure the correct num visible. | 189 // Add the max visible popup notifications +1, ensure the correct num visible. |
| 190 size_t notifications_to_add = kMaxVisiblePopupNotifications + 1; | 190 size_t notifications_to_add = kMaxVisiblePopupNotifications + 1; |
| 191 for (size_t i = 0; i < notifications_to_add; ++i) { | 191 for (size_t i = 0; i < notifications_to_add; ++i) { |
| 192 std::string id = base::StringPrintf("test_id%d", static_cast<int>(i)); | 192 std::string id = base::StringPrintf("test_id%d", static_cast<int>(i)); |
| 193 std::string replace_id = | 193 std::string replace_id = |
| 194 base::StringPrintf("replace_id%d", static_cast<int>(i)); | 194 base::StringPrintf("replace_id%d", static_cast<int>(i)); |
| 195 AddNotification(id, replace_id); | 195 AddNotification(id, replace_id); |
| 196 } | 196 } |
| (...skipping 25 matching lines...) Expand all Loading... |
| 222 EXPECT_TRUE(message_center->IsMessageCenterVisible()); | 222 EXPECT_TRUE(message_center->IsMessageCenterVisible()); |
| 223 | 223 |
| 224 mc_manager->EnsureMessageCenterClosed(); | 224 mc_manager->EnsureMessageCenterClosed(); |
| 225 | 225 |
| 226 EXPECT_FALSE(message_center->IsMessageCenterVisible()); | 226 EXPECT_FALSE(message_center->IsMessageCenterVisible()); |
| 227 if (NULL != tray->message_center_delegate_) | 227 if (NULL != tray->message_center_delegate_) |
| 228 EXPECT_TRUE(tray->message_center_delegate_->GetWidget()->IsClosed()); | 228 EXPECT_TRUE(tray->message_center_delegate_->GetWidget()->IsClosed()); |
| 229 } | 229 } |
| 230 | 230 |
| 231 } // namespace message_center | 231 } // namespace message_center |
| OLD | NEW |