| 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 #include "ui/message_center/message_center_tray.h" | 5 #include "ui/message_center/message_center_tray.h" |
| 6 | 6 |
| 7 #include "base/strings/utf_string_conversions.h" | 7 #include "base/strings/utf_string_conversions.h" |
| 8 #include "testing/gtest/include/gtest/gtest.h" | 8 #include "testing/gtest/include/gtest/gtest.h" |
| 9 #include "ui/base/models/menu_model.h" | 9 #include "ui/base/models/menu_model.h" |
| 10 #include "ui/message_center/message_center.h" | 10 #include "ui/message_center/message_center.h" |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 62 message_center_ = NULL; | 62 message_center_ = NULL; |
| 63 MessageCenter::Shutdown(); | 63 MessageCenter::Shutdown(); |
| 64 } | 64 } |
| 65 | 65 |
| 66 protected: | 66 protected: |
| 67 NotifierId DummyNotifierId() { | 67 NotifierId DummyNotifierId() { |
| 68 return NotifierId(); | 68 return NotifierId(); |
| 69 } | 69 } |
| 70 | 70 |
| 71 void AddNotification(const std::string& id) { | 71 void AddNotification(const std::string& id) { |
| 72 scoped_ptr<Notification> notification( | 72 scoped_ptr<Notification> notification(new Notification( |
| 73 new Notification(message_center::NOTIFICATION_TYPE_SIMPLE, | 73 message_center::NOTIFICATION_TYPE_SIMPLE, id, |
| 74 id, | 74 ASCIIToUTF16("Test Web Notification"), |
| 75 ASCIIToUTF16("Test Web Notification"), | 75 ASCIIToUTF16("Notification message body."), gfx::Image(), |
| 76 ASCIIToUTF16("Notification message body."), | 76 ASCIIToUTF16("www.test.org"), GURL(), DummyNotifierId(), |
| 77 gfx::Image(), | 77 message_center::RichNotificationData(), NULL /* delegate */)); |
| 78 ASCIIToUTF16("www.test.org"), | |
| 79 DummyNotifierId(), | |
| 80 message_center::RichNotificationData(), | |
| 81 NULL /* delegate */)); | |
| 82 message_center_->AddNotification(notification.Pass()); | 78 message_center_->AddNotification(notification.Pass()); |
| 83 } | 79 } |
| 84 scoped_ptr<MockDelegate> delegate_; | 80 scoped_ptr<MockDelegate> delegate_; |
| 85 scoped_ptr<MessageCenterTray> message_center_tray_; | 81 scoped_ptr<MessageCenterTray> message_center_tray_; |
| 86 MessageCenter* message_center_; | 82 MessageCenter* message_center_; |
| 87 | 83 |
| 88 private: | 84 private: |
| 89 DISALLOW_COPY_AND_ASSIGN(MessageCenterTrayTest); | 85 DISALLOW_COPY_AND_ASSIGN(MessageCenterTrayTest); |
| 90 }; | 86 }; |
| 91 | 87 |
| (...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 167 message_center_tray_->ShowMessageCenterBubble(); | 163 message_center_tray_->ShowMessageCenterBubble(); |
| 168 message_center_tray_->HideMessageCenterBubble(); | 164 message_center_tray_->HideMessageCenterBubble(); |
| 169 ASSERT_FALSE(message_center_tray_->popups_visible()); | 165 ASSERT_FALSE(message_center_tray_->popups_visible()); |
| 170 ASSERT_FALSE(message_center_tray_->message_center_visible()); | 166 ASSERT_FALSE(message_center_tray_->message_center_visible()); |
| 171 } | 167 } |
| 172 | 168 |
| 173 TEST_F(MessageCenterTrayTest, MessageCenterReopenPopupsForSystemPriority) { | 169 TEST_F(MessageCenterTrayTest, MessageCenterReopenPopupsForSystemPriority) { |
| 174 ASSERT_FALSE(message_center_tray_->popups_visible()); | 170 ASSERT_FALSE(message_center_tray_->popups_visible()); |
| 175 ASSERT_FALSE(message_center_tray_->message_center_visible()); | 171 ASSERT_FALSE(message_center_tray_->message_center_visible()); |
| 176 | 172 |
| 177 scoped_ptr<Notification> notification( | 173 scoped_ptr<Notification> notification(new Notification( |
| 178 new Notification(message_center::NOTIFICATION_TYPE_SIMPLE, | 174 message_center::NOTIFICATION_TYPE_SIMPLE, |
| 179 "MessageCenterReopnPopupsForSystemPriority", | 175 "MessageCenterReopnPopupsForSystemPriority", |
| 180 ASCIIToUTF16("Test Web Notification"), | 176 ASCIIToUTF16("Test Web Notification"), |
| 181 ASCIIToUTF16("Notification message body."), | 177 ASCIIToUTF16("Notification message body."), gfx::Image(), |
| 182 gfx::Image(), | 178 ASCIIToUTF16("www.test.org"), GURL(), DummyNotifierId(), |
| 183 ASCIIToUTF16("www.test.org"), | 179 message_center::RichNotificationData(), NULL /* delegate */)); |
| 184 DummyNotifierId(), | |
| 185 message_center::RichNotificationData(), | |
| 186 NULL /* delegate */)); | |
| 187 notification->SetSystemPriority(); | 180 notification->SetSystemPriority(); |
| 188 message_center_->AddNotification(notification.Pass()); | 181 message_center_->AddNotification(notification.Pass()); |
| 189 | 182 |
| 190 ASSERT_TRUE(message_center_tray_->popups_visible()); | 183 ASSERT_TRUE(message_center_tray_->popups_visible()); |
| 191 ASSERT_FALSE(message_center_tray_->message_center_visible()); | 184 ASSERT_FALSE(message_center_tray_->message_center_visible()); |
| 192 | 185 |
| 193 bool shown = message_center_tray_->ShowMessageCenterBubble(); | 186 bool shown = message_center_tray_->ShowMessageCenterBubble(); |
| 194 EXPECT_TRUE(shown); | 187 EXPECT_TRUE(shown); |
| 195 | 188 |
| 196 ASSERT_FALSE(message_center_tray_->popups_visible()); | 189 ASSERT_FALSE(message_center_tray_->popups_visible()); |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 242 TEST_F(MessageCenterTrayTest, ContextMenuTest) { | 235 TEST_F(MessageCenterTrayTest, ContextMenuTest) { |
| 243 const std::string id1 = "id1"; | 236 const std::string id1 = "id1"; |
| 244 const std::string id2 = "id2"; | 237 const std::string id2 = "id2"; |
| 245 const std::string id3 = "id3"; | 238 const std::string id3 = "id3"; |
| 246 AddNotification(id1); | 239 AddNotification(id1); |
| 247 | 240 |
| 248 base::string16 display_source = ASCIIToUTF16("www.test.org"); | 241 base::string16 display_source = ASCIIToUTF16("www.test.org"); |
| 249 NotifierId notifier_id = DummyNotifierId(); | 242 NotifierId notifier_id = DummyNotifierId(); |
| 250 | 243 |
| 251 NotifierId notifier_id2(NotifierId::APPLICATION, "sample-app"); | 244 NotifierId notifier_id2(NotifierId::APPLICATION, "sample-app"); |
| 252 scoped_ptr<Notification> notification( | 245 scoped_ptr<Notification> notification(new Notification( |
| 253 new Notification(message_center::NOTIFICATION_TYPE_SIMPLE, | 246 message_center::NOTIFICATION_TYPE_SIMPLE, id2, |
| 254 id2, | 247 ASCIIToUTF16("Test Web Notification"), |
| 255 ASCIIToUTF16("Test Web Notification"), | 248 ASCIIToUTF16("Notification message body."), gfx::Image(), |
| 256 ASCIIToUTF16("Notification message body."), | 249 base::string16() /* empty display source */, GURL(), notifier_id2, |
| 257 gfx::Image(), | 250 message_center::RichNotificationData(), NULL /* delegate */)); |
| 258 base::string16() /* empty display source */, | |
| 259 notifier_id2, | |
| 260 message_center::RichNotificationData(), | |
| 261 NULL /* delegate */)); | |
| 262 message_center_->AddNotification(notification.Pass()); | 251 message_center_->AddNotification(notification.Pass()); |
| 263 | 252 |
| 264 AddNotification(id3); | 253 AddNotification(id3); |
| 265 | 254 |
| 266 scoped_ptr<ui::MenuModel> model( | 255 scoped_ptr<ui::MenuModel> model( |
| 267 message_center_tray_->CreateNotificationMenuModel( | 256 message_center_tray_->CreateNotificationMenuModel( |
| 268 notifier_id, display_source)); | 257 notifier_id, display_source)); |
| 269 EXPECT_EQ(2, model->GetItemCount()); | 258 EXPECT_EQ(2, model->GetItemCount()); |
| 270 const int second_command = model->GetCommandIdAt(1); | 259 const int second_command = model->GetCommandIdAt(1); |
| 271 | 260 |
| (...skipping 21 matching lines...) Expand all Loading... |
| 293 model = message_center_tray_->CreateNotificationMenuModel( | 282 model = message_center_tray_->CreateNotificationMenuModel( |
| 294 notifier_id2, base::string16()); | 283 notifier_id2, base::string16()); |
| 295 EXPECT_EQ(1, model->GetItemCount()); | 284 EXPECT_EQ(1, model->GetItemCount()); |
| 296 EXPECT_EQ(second_command, model->GetCommandIdAt(0)); | 285 EXPECT_EQ(second_command, model->GetCommandIdAt(0)); |
| 297 | 286 |
| 298 // The command itself is disabled because delegate disables context menu. | 287 // The command itself is disabled because delegate disables context menu. |
| 299 EXPECT_FALSE(model->IsEnabledAt(0)); | 288 EXPECT_FALSE(model->IsEnabledAt(0)); |
| 300 } | 289 } |
| 301 | 290 |
| 302 } // namespace message_center | 291 } // namespace message_center |
| OLD | NEW |