OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "ash/system/web_notification/web_notification_tray.h" | 5 #include "ash/system/web_notification/web_notification_tray.h" |
6 | 6 |
7 #include <vector> | 7 #include <vector> |
8 | 8 |
9 #include "ash/root_window_controller.h" | 9 #include "ash/root_window_controller.h" |
10 #include "ash/shelf/shelf_widget.h" | 10 #include "ash/shelf/shelf_widget.h" |
11 #include "ash/system/status_area_widget.h" | 11 #include "ash/system/status_area_widget.h" |
12 #include "ash/system/tray/system_tray_item.h" | 12 #include "ash/system/tray/system_tray_item.h" |
13 #include "ash/test/ash_test_base.h" | 13 #include "ash/test/ash_test_base.h" |
14 #include "base/stringprintf.h" | 14 #include "base/stringprintf.h" |
15 #include "base/utf_string_conversions.h" | 15 #include "base/utf_string_conversions.h" |
| 16 #include "ui/message_center/message_center_constants.h" |
16 #include "ui/message_center/message_center_tray.h" | 17 #include "ui/message_center/message_center_tray.h" |
17 #include "ui/message_center/message_center_util.h" | 18 #include "ui/message_center/message_center_util.h" |
18 #include "ui/message_center/notification_list.h" | 19 #include "ui/message_center/notification_list.h" |
19 #include "ui/message_center/notification_types.h" | 20 #include "ui/message_center/notification_types.h" |
20 #include "ui/message_center/views/message_center_bubble.h" | 21 #include "ui/message_center/views/message_center_bubble.h" |
21 #include "ui/message_center/views/message_popup_bubble.h" | 22 #include "ui/message_center/views/message_popup_bubble.h" |
22 #include "ui/message_center/views/message_popup_collection.h" | 23 #include "ui/message_center/views/message_popup_collection.h" |
23 #include "ui/views/controls/label.h" | 24 #include "ui/views/controls/label.h" |
24 #include "ui/views/layout/fill_layout.h" | 25 #include "ui/views/layout/fill_layout.h" |
25 #include "ui/views/view.h" | 26 #include "ui/views/view.h" |
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
139 EXPECT_FALSE(GetTray()->IsPopupVisible()); | 140 EXPECT_FALSE(GetTray()->IsPopupVisible()); |
140 } | 141 } |
141 | 142 |
142 using message_center::NotificationList; | 143 using message_center::NotificationList; |
143 | 144 |
144 | 145 |
145 // Flakily fails. http://crbug.com/229791 | 146 // Flakily fails. http://crbug.com/229791 |
146 TEST_F(WebNotificationTrayTest, DISABLED_ManyMessageCenterNotifications) { | 147 TEST_F(WebNotificationTrayTest, DISABLED_ManyMessageCenterNotifications) { |
147 // Add the max visible notifications +1, ensure the correct visible number. | 148 // Add the max visible notifications +1, ensure the correct visible number. |
148 size_t notifications_to_add = | 149 size_t notifications_to_add = |
149 NotificationList::kMaxVisibleMessageCenterNotifications + 1; | 150 message_center::kMaxVisibleMessageCenterNotifications + 1; |
150 for (size_t i = 0; i < notifications_to_add; ++i) { | 151 for (size_t i = 0; i < notifications_to_add; ++i) { |
151 std::string id = base::StringPrintf("test_id%d", static_cast<int>(i)); | 152 std::string id = base::StringPrintf("test_id%d", static_cast<int>(i)); |
152 AddNotification(id); | 153 AddNotification(id); |
153 } | 154 } |
154 bool shown = GetTray()->message_center_tray_->ShowMessageCenterBubble(); | 155 bool shown = GetTray()->message_center_tray_->ShowMessageCenterBubble(); |
155 EXPECT_TRUE(shown); | 156 EXPECT_TRUE(shown); |
156 RunAllPendingInMessageLoop(); | 157 RunAllPendingInMessageLoop(); |
157 EXPECT_TRUE(GetTray()->message_center_bubble() != NULL); | 158 EXPECT_TRUE(GetTray()->message_center_bubble() != NULL); |
158 EXPECT_EQ(notifications_to_add, | 159 EXPECT_EQ(notifications_to_add, |
159 GetMessageCenter()->NotificationCount()); | 160 GetMessageCenter()->NotificationCount()); |
160 EXPECT_EQ(NotificationList::kMaxVisibleMessageCenterNotifications, | 161 EXPECT_EQ(message_center::kMaxVisibleMessageCenterNotifications, |
161 GetTray()->GetMessageCenterBubbleForTest()-> | 162 GetTray()->GetMessageCenterBubbleForTest()-> |
162 NumMessageViewsForTest()); | 163 NumMessageViewsForTest()); |
163 } | 164 } |
164 | 165 |
165 // Flakily times out. http://crbug.com/229792 | 166 // Flakily times out. http://crbug.com/229792 |
166 TEST_F(WebNotificationTrayTest, DISABLED_ManyPopupNotifications) { | 167 TEST_F(WebNotificationTrayTest, DISABLED_ManyPopupNotifications) { |
167 // Add the max visible popup notifications +1, ensure the correct num visible. | 168 // Add the max visible popup notifications +1, ensure the correct num visible. |
168 size_t notifications_to_add = | 169 size_t notifications_to_add = |
169 NotificationList::kMaxVisiblePopupNotifications + 1; | 170 message_center::kMaxVisiblePopupNotifications + 1; |
170 for (size_t i = 0; i < notifications_to_add; ++i) { | 171 for (size_t i = 0; i < notifications_to_add; ++i) { |
171 std::string id = base::StringPrintf("test_id%d", static_cast<int>(i)); | 172 std::string id = base::StringPrintf("test_id%d", static_cast<int>(i)); |
172 AddNotification(id); | 173 AddNotification(id); |
173 } | 174 } |
174 // Hide and reshow the bubble so that it is updated immediately, not delayed. | 175 // Hide and reshow the bubble so that it is updated immediately, not delayed. |
175 GetTray()->SetHidePopupBubble(true); | 176 GetTray()->SetHidePopupBubble(true); |
176 GetTray()->SetHidePopupBubble(false); | 177 GetTray()->SetHidePopupBubble(false); |
177 EXPECT_TRUE(GetTray()->IsPopupVisible()); | 178 EXPECT_TRUE(GetTray()->IsPopupVisible()); |
178 EXPECT_EQ(notifications_to_add, | 179 EXPECT_EQ(notifications_to_add, |
179 GetMessageCenter()->NotificationCount()); | 180 GetMessageCenter()->NotificationCount()); |
180 if (message_center::IsRichNotificationEnabled()) { | 181 if (message_center::IsRichNotificationEnabled()) { |
181 NotificationList::PopupNotifications popups = | 182 NotificationList::PopupNotifications popups = |
182 GetMessageCenter()->GetPopupNotifications(); | 183 GetMessageCenter()->GetPopupNotifications(); |
183 EXPECT_EQ(NotificationList::kMaxVisiblePopupNotifications, popups.size()); | 184 EXPECT_EQ(message_center::kMaxVisiblePopupNotifications, popups.size()); |
184 } else { | 185 } else { |
185 EXPECT_EQ(NotificationList::kMaxVisiblePopupNotifications, | 186 EXPECT_EQ(message_center::kMaxVisiblePopupNotifications, |
186 GetTray()->GetPopupBubbleForTest()->NumMessageViewsForTest()); | 187 GetTray()->GetPopupBubbleForTest()->NumMessageViewsForTest()); |
187 } | 188 } |
188 } | 189 } |
189 | 190 |
190 } // namespace ash | 191 } // namespace ash |
OLD | NEW |