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

Side by Side Diff: chrome/browser/push_messaging/push_messaging_browsertest.cc

Issue 1149243005: Automatically close the default push notification when a real one appears. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 6 months 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
« no previous file with comments | « no previous file | chrome/browser/push_messaging/push_messaging_notification_manager.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 <map> 5 #include <map>
6 #include <string> 6 #include <string>
7 7
8 #include "base/barrier_closure.h" 8 #include "base/barrier_closure.h"
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/command_line.h" 10 #include "base/command_line.h"
(...skipping 543 matching lines...) Expand 10 before | Expand all | Expand 10 after
554 message.data["data"] = "testdata"; 554 message.data["data"] = "testdata";
555 SendMessageAndWaitUntilHandled(app_identifier, message); 555 SendMessageAndWaitUntilHandled(app_identifier, message);
556 ASSERT_TRUE(RunScript("resultQueue.pop()", &script_result, web_contents)); 556 ASSERT_TRUE(RunScript("resultQueue.pop()", &script_result, web_contents));
557 EXPECT_EQ("testdata", script_result); 557 EXPECT_EQ("testdata", script_result);
558 EXPECT_EQ(0u, notification_manager()->GetNotificationCount()); 558 EXPECT_EQ(0u, notification_manager()->GetNotificationCount());
559 message.data["data"] = "testdata"; 559 message.data["data"] = "testdata";
560 SendMessageAndWaitUntilHandled(app_identifier, message); 560 SendMessageAndWaitUntilHandled(app_identifier, message);
561 ASSERT_TRUE(RunScript("resultQueue.pop()", &script_result, web_contents)); 561 ASSERT_TRUE(RunScript("resultQueue.pop()", &script_result, web_contents));
562 EXPECT_EQ("testdata", script_result); 562 EXPECT_EQ("testdata", script_result);
563 563
564 EXPECT_EQ(1u, notification_manager()->GetNotificationCount()); 564 ASSERT_EQ(1u, notification_manager()->GetNotificationCount());
565 const Notification& forced_notification = 565 {
566 notification_manager()->GetNotificationAt(0); 566 const Notification& forced_notification =
567 notification_manager()->GetNotificationAt(0);
567 568
568 EXPECT_EQ(kPushMessagingForcedNotificationTag, forced_notification.tag()); 569 EXPECT_EQ(kPushMessagingForcedNotificationTag, forced_notification.tag());
569 EXPECT_TRUE(forced_notification.silent()); 570 EXPECT_TRUE(forced_notification.silent());
571 }
570 572
571 // Currently, this notification will stick around until the user or webapp 573 // The notification will be automatically dismissed when the developer shows
572 // explicitly dismisses it (though we may change this later). 574 // a new notification themselves at a later point in time.
573 message.data["data"] = "shownotification"; 575 message.data["data"] = "shownotification";
574 SendMessageAndWaitUntilHandled(app_identifier, message); 576 SendMessageAndWaitUntilHandled(app_identifier, message);
575 ASSERT_TRUE(RunScript("resultQueue.pop()", &script_result, web_contents)); 577 ASSERT_TRUE(RunScript("resultQueue.pop()", &script_result, web_contents));
576 EXPECT_EQ("shownotification", script_result); 578 EXPECT_EQ("shownotification", script_result);
577 EXPECT_EQ(2u, notification_manager()->GetNotificationCount()); 579
580 ASSERT_EQ(1u, notification_manager()->GetNotificationCount());
581 {
582 const Notification& first_notification =
583 notification_manager()->GetNotificationAt(0);
584
585 EXPECT_NE(kPushMessagingForcedNotificationTag, first_notification.tag());
586 }
578 587
579 notification_manager()->CancelAll(); 588 notification_manager()->CancelAll();
580 EXPECT_EQ(0u, notification_manager()->GetNotificationCount()); 589 EXPECT_EQ(0u, notification_manager()->GetNotificationCount());
581 590
582 // However if the Service Worker push event handler shows a notification, we 591 // However if the Service Worker push event handler shows a notification, we
583 // should not show a forced one. 592 // should not show a forced one.
584 message.data["data"] = "shownotification"; 593 message.data["data"] = "shownotification";
585 for (int n = 0; n < 9; n++) { 594 for (int n = 0; n < 9; n++) {
586 SendMessageAndWaitUntilHandled(app_identifier, message); 595 SendMessageAndWaitUntilHandled(app_identifier, message);
587 ASSERT_TRUE(RunScript("resultQueue.pop()", &script_result, web_contents)); 596 ASSERT_TRUE(RunScript("resultQueue.pop()", &script_result, web_contents));
(...skipping 509 matching lines...) Expand 10 before | Expand all | Expand 10 after
1097 std::string script_result; 1106 std::string script_result;
1098 1107
1099 ASSERT_TRUE(RunScript("registerServiceWorker()", &script_result)); 1108 ASSERT_TRUE(RunScript("registerServiceWorker()", &script_result));
1100 ASSERT_EQ("ok - service worker registered", script_result); 1109 ASSERT_EQ("ok - service worker registered", script_result);
1101 1110
1102 // In Incognito mode the promise returned by getSubscription should not hang, 1111 // In Incognito mode the promise returned by getSubscription should not hang,
1103 // it should just fulfill with null. 1112 // it should just fulfill with null.
1104 ASSERT_TRUE(RunScript("hasSubscription()", &script_result)); 1113 ASSERT_TRUE(RunScript("hasSubscription()", &script_result));
1105 ASSERT_EQ("false - not subscribed", script_result); 1114 ASSERT_EQ("false - not subscribed", script_result);
1106 } 1115 }
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/push_messaging/push_messaging_notification_manager.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698