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 <deque> | 5 #include <deque> |
6 #include <string> | 6 #include <string> |
7 | 7 |
8 #include "base/bind.h" | 8 #include "base/bind.h" |
9 #include "base/callback.h" | 9 #include "base/callback.h" |
10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
11 #include "base/compiler_specific.h" | 11 #include "base/compiler_specific.h" |
12 #include "base/memory/ref_counted.h" | 12 #include "base/memory/ref_counted.h" |
13 #include "base/run_loop.h" | 13 #include "base/run_loop.h" |
14 #include "base/strings/stringprintf.h" | 14 #include "base/strings/stringprintf.h" |
15 #include "base/strings/utf_string_conversions.h" | 15 #include "base/strings/utf_string_conversions.h" |
16 #include "chrome/browser/browser_process.h" | 16 #include "chrome/browser/browser_process.h" |
17 #include "chrome/browser/chrome_notification_types.h" | 17 #include "chrome/browser/chrome_notification_types.h" |
18 #include "chrome/browser/infobars/confirm_infobar_delegate.h" | 18 #include "chrome/browser/infobars/confirm_infobar_delegate.h" |
19 #include "chrome/browser/infobars/infobar.h" | |
20 #include "chrome/browser/infobars/infobar_service.h" | 19 #include "chrome/browser/infobars/infobar_service.h" |
21 #include "chrome/browser/notifications/balloon.h" | 20 #include "chrome/browser/notifications/balloon.h" |
22 #include "chrome/browser/notifications/balloon_collection.h" | 21 #include "chrome/browser/notifications/balloon_collection.h" |
23 #include "chrome/browser/notifications/balloon_host.h" | 22 #include "chrome/browser/notifications/balloon_host.h" |
24 #include "chrome/browser/notifications/balloon_notification_ui_manager.h" | 23 #include "chrome/browser/notifications/balloon_notification_ui_manager.h" |
25 #include "chrome/browser/notifications/desktop_notification_service.h" | 24 #include "chrome/browser/notifications/desktop_notification_service.h" |
26 #include "chrome/browser/notifications/desktop_notification_service_factory.h" | 25 #include "chrome/browser/notifications/desktop_notification_service_factory.h" |
27 #include "chrome/browser/notifications/notification.h" | 26 #include "chrome/browser/notifications/notification.h" |
28 #include "chrome/browser/profiles/profile.h" | 27 #include "chrome/browser/profiles/profile.h" |
29 #include "chrome/browser/ui/browser.h" | 28 #include "chrome/browser/ui/browser.h" |
(...skipping 284 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
314 GetDesktopNotificationService()->SetDefaultContentSetting( | 313 GetDesktopNotificationService()->SetDefaultContentSetting( |
315 CONTENT_SETTING_ALLOW); | 314 CONTENT_SETTING_ALLOW); |
316 } | 315 } |
317 | 316 |
318 void NotificationsTest::VerifyInfoBar(const Browser* browser, int index) { | 317 void NotificationsTest::VerifyInfoBar(const Browser* browser, int index) { |
319 InfoBarService* infobar_service = InfoBarService::FromWebContents( | 318 InfoBarService* infobar_service = InfoBarService::FromWebContents( |
320 browser->tab_strip_model()->GetWebContentsAt(index)); | 319 browser->tab_strip_model()->GetWebContentsAt(index)); |
321 | 320 |
322 ASSERT_EQ(1U, infobar_service->infobar_count()); | 321 ASSERT_EQ(1U, infobar_service->infobar_count()); |
323 ConfirmInfoBarDelegate* confirm_infobar = | 322 ConfirmInfoBarDelegate* confirm_infobar = |
324 infobar_service->infobar_at(0)->delegate()->AsConfirmInfoBarDelegate(); | 323 infobar_service->infobar_at(0)->AsConfirmInfoBarDelegate(); |
325 ASSERT_TRUE(confirm_infobar); | 324 ASSERT_TRUE(confirm_infobar); |
326 int buttons = confirm_infobar->GetButtons(); | 325 int buttons = confirm_infobar->GetButtons(); |
327 EXPECT_TRUE(buttons & ConfirmInfoBarDelegate::BUTTON_OK); | 326 EXPECT_TRUE(buttons & ConfirmInfoBarDelegate::BUTTON_OK); |
328 EXPECT_TRUE(buttons & ConfirmInfoBarDelegate::BUTTON_CANCEL); | 327 EXPECT_TRUE(buttons & ConfirmInfoBarDelegate::BUTTON_CANCEL); |
329 } | 328 } |
330 | 329 |
331 std::string NotificationsTest::CreateNotification( | 330 std::string NotificationsTest::CreateNotification( |
332 Browser* browser, | 331 Browser* browser, |
333 bool wait_for_new_balloon, | 332 bool wait_for_new_balloon, |
334 const char* icon, | 333 const char* icon, |
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
400 InfobarAction action, | 399 InfobarAction action, |
401 size_t infobar_index, | 400 size_t infobar_index, |
402 int tab_index) { | 401 int tab_index) { |
403 InfoBarService* infobar_service = InfoBarService::FromWebContents( | 402 InfoBarService* infobar_service = InfoBarService::FromWebContents( |
404 browser->tab_strip_model()->GetWebContentsAt(tab_index)); | 403 browser->tab_strip_model()->GetWebContentsAt(tab_index)); |
405 if (infobar_index >= infobar_service->infobar_count()) { | 404 if (infobar_index >= infobar_service->infobar_count()) { |
406 ADD_FAILURE(); | 405 ADD_FAILURE(); |
407 return false; | 406 return false; |
408 } | 407 } |
409 | 408 |
410 InfoBar* infobar = infobar_service->infobar_at(infobar_index); | 409 InfoBarDelegate* infobar_delegate = |
411 InfoBarDelegate* infobar_delegate = infobar->delegate(); | 410 infobar_service->infobar_at(infobar_index); |
412 switch (action) { | 411 switch (action) { |
413 case DISMISS: | 412 case DISMISS: |
414 infobar_delegate->InfoBarDismissed(); | 413 infobar_delegate->InfoBarDismissed(); |
415 infobar_service->RemoveInfoBar(infobar); | 414 infobar_service->RemoveInfoBar(infobar_delegate); |
416 return true; | 415 return true; |
417 | 416 |
418 case ALLOW: { | 417 case ALLOW: { |
419 ConfirmInfoBarDelegate* confirm_infobar_delegate = | 418 ConfirmInfoBarDelegate* confirm_infobar_delegate = |
420 infobar_delegate->AsConfirmInfoBarDelegate(); | 419 infobar_delegate->AsConfirmInfoBarDelegate(); |
421 if (!confirm_infobar_delegate) { | 420 if (!confirm_infobar_delegate) { |
422 ADD_FAILURE(); | 421 ADD_FAILURE(); |
423 } else if (confirm_infobar_delegate->Accept()) { | 422 } else if (confirm_infobar_delegate->Accept()) { |
424 infobar_service->RemoveInfoBar(infobar); | 423 infobar_service->RemoveInfoBar(infobar_delegate); |
425 return true; | 424 return true; |
426 } | 425 } |
427 } | 426 } |
428 | 427 |
429 case DENY: { | 428 case DENY: { |
430 ConfirmInfoBarDelegate* confirm_infobar_delegate = | 429 ConfirmInfoBarDelegate* confirm_infobar_delegate = |
431 infobar_delegate->AsConfirmInfoBarDelegate(); | 430 infobar_delegate->AsConfirmInfoBarDelegate(); |
432 if (!confirm_infobar_delegate) { | 431 if (!confirm_infobar_delegate) { |
433 ADD_FAILURE(); | 432 ADD_FAILURE(); |
434 } else if (confirm_infobar_delegate->Cancel()) { | 433 } else if (confirm_infobar_delegate->Cancel()) { |
435 infobar_service->RemoveInfoBar(infobar); | 434 infobar_service->RemoveInfoBar(infobar_delegate); |
436 return true; | 435 return true; |
437 } | 436 } |
438 } | 437 } |
439 } | 438 } |
440 | 439 |
441 return false; | 440 return false; |
442 } | 441 } |
443 | 442 |
444 void NotificationsTest::GetPrefsByContentSetting( | 443 void NotificationsTest::GetPrefsByContentSetting( |
445 ContentSetting setting, | 444 ContentSetting setting, |
(...skipping 496 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
942 const std::deque<Balloon*>& balloons = GetActiveBalloons(); | 941 const std::deque<Balloon*>& balloons = GetActiveBalloons(); |
943 ASSERT_EQ(1U, balloons.size()); | 942 ASSERT_EQ(1U, balloons.size()); |
944 Balloon* balloon = balloons[0]; | 943 Balloon* balloon = balloons[0]; |
945 const Notification& notification = balloon->notification(); | 944 const Notification& notification = balloon->notification(); |
946 GURL EXPECTED_ICON_URL = embedded_test_server()->GetURL(kExpectedIconUrl); | 945 GURL EXPECTED_ICON_URL = embedded_test_server()->GetURL(kExpectedIconUrl); |
947 EXPECT_EQ(EXPECTED_ICON_URL, notification.icon_url()); | 946 EXPECT_EQ(EXPECTED_ICON_URL, notification.icon_url()); |
948 EXPECT_EQ(ASCIIToUTF16("Title2"), notification.title()); | 947 EXPECT_EQ(ASCIIToUTF16("Title2"), notification.title()); |
949 EXPECT_EQ(ASCIIToUTF16("Body2"), notification.message()); | 948 EXPECT_EQ(ASCIIToUTF16("Body2"), notification.message()); |
950 } | 949 } |
951 } | 950 } |
OLD | NEW |