Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(36)

Side by Side Diff: chrome/browser/notifications/notification_browsertest.cc

Issue 802753002: Revert of "Call the Close() event on a Notification when it's being replaced." (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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"
(...skipping 747 matching lines...) Expand 10 before | Expand all | Expand 10 after
758 } 758 }
759 759
760 IN_PROC_BROWSER_TEST_F(NotificationsTest, TestNotificationReplacement) { 760 IN_PROC_BROWSER_TEST_F(NotificationsTest, TestNotificationReplacement) {
761 ASSERT_TRUE(embedded_test_server()->InitializeAndWaitUntilReady()); 761 ASSERT_TRUE(embedded_test_server()->InitializeAndWaitUntilReady());
762 762
763 // Test that we can replace a notification using the replaceId. 763 // Test that we can replace a notification using the replaceId.
764 AllowAllOrigins(); 764 AllowAllOrigins();
765 765
766 ui_test_utils::NavigateToURL(browser(), GetTestPageURL()); 766 ui_test_utils::NavigateToURL(browser(), GetTestPageURL());
767 767
768 std::string original_result = CreateNotification( 768 std::string result = CreateNotification(
769 browser(), true, "abc.png", "Title1", "Body1", "chat"); 769 browser(), true, "abc.png", "Title1", "Body1", "chat");
770 EXPECT_NE("-1", original_result); 770 EXPECT_NE("-1", result);
771 771
772 ASSERT_EQ(1, GetNotificationCount()); 772 ASSERT_EQ(1, GetNotificationCount());
773 773
774 std::string replaced_result = CreateNotification( 774 result = CreateNotification(
775 browser(), false, "no_such_file.png", "Title2", "Body2", "chat"); 775 browser(), false, "no_such_file.png", "Title2", "Body2", "chat");
776 EXPECT_NE("-1", replaced_result); 776 EXPECT_NE("-1", result);
777 777
778 ASSERT_EQ(1, GetNotificationCount()); 778 ASSERT_EQ(1, GetNotificationCount());
779 message_center::NotificationList::Notifications notifications = 779 message_center::NotificationList::Notifications notifications =
780 message_center::MessageCenter::Get()->GetVisibleNotifications(); 780 message_center::MessageCenter::Get()->GetVisibleNotifications();
781 EXPECT_EQ(base::ASCIIToUTF16("Title2"), (*notifications.rbegin())->title()); 781 EXPECT_EQ(base::ASCIIToUTF16("Title2"), (*notifications.rbegin())->title());
782 EXPECT_EQ(base::ASCIIToUTF16("Body2"), 782 EXPECT_EQ(base::ASCIIToUTF16("Body2"),
783 (*notifications.rbegin())->message()); 783 (*notifications.rbegin())->message());
784
785 std::string result;
786 bool success = content::ExecuteScriptAndExtractString(
787 browser()->tab_strip_model()->GetActiveWebContents(),
788 std::string("hasBeenClosed(") + original_result + ");",
789 &result);
790
791 EXPECT_TRUE(success);
792 EXPECT_EQ(result, "true");
793 } 784 }
794 785
795 IN_PROC_BROWSER_TEST_F(NotificationsTest, TestLastUsage) { 786 IN_PROC_BROWSER_TEST_F(NotificationsTest, TestLastUsage) {
796 ASSERT_TRUE(embedded_test_server()->InitializeAndWaitUntilReady()); 787 ASSERT_TRUE(embedded_test_server()->InitializeAndWaitUntilReady());
797 788
798 HostContentSettingsMap* settings_map = 789 HostContentSettingsMap* settings_map =
799 browser()->profile()->GetHostContentSettingsMap(); 790 browser()->profile()->GetHostContentSettingsMap();
800 base::SimpleTestClock* clock = new base::SimpleTestClock(); 791 base::SimpleTestClock* clock = new base::SimpleTestClock();
801 settings_map->SetPrefClockForTesting(scoped_ptr<base::Clock>(clock)); 792 settings_map->SetPrefClockForTesting(scoped_ptr<base::Clock>(clock));
802 clock->SetNow(base::Time::UnixEpoch() + base::TimeDelta::FromSeconds(10)); 793 clock->SetNow(base::Time::UnixEpoch() + base::TimeDelta::FromSeconds(10));
(...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after
930 true); // by_user 921 true); // by_user
931 922
932 ASSERT_EQ(0, GetNotificationCount()); 923 ASSERT_EQ(0, GetNotificationCount());
933 924
934 // Calling WebContents::IsCrashed() will return FALSE here, even if the WC did 925 // Calling WebContents::IsCrashed() will return FALSE here, even if the WC did
935 // crash. Work around this timing issue by creating another notification, 926 // crash. Work around this timing issue by creating another notification,
936 // which requires interaction with the renderer process. 927 // which requires interaction with the renderer process.
937 result = CreateNotification(browser(), true, "", "Title1", "Body1", "chat"); 928 result = CreateNotification(browser(), true, "", "Title1", "Body1", "chat");
938 EXPECT_NE("-1", result); 929 EXPECT_NE("-1", result);
939 } 930 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698