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

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

Issue 1093923005: Swap hasPermission with permissionState in browser_tests (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 7 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_service_impl.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 551 matching lines...) Expand 10 before | Expand all | Expand 10 after
562 ASSERT_EQ(1u, notification_manager()->GetNotificationCount()); 562 ASSERT_EQ(1u, notification_manager()->GetNotificationCount());
563 EXPECT_EQ("push_test_tag", 563 EXPECT_EQ("push_test_tag",
564 notification_manager()->GetNotificationAt(0).tag()); 564 notification_manager()->GetNotificationAt(0).tag());
565 565
566 // Verify that the renderer process hasn't crashed. 566 // Verify that the renderer process hasn't crashed.
567 ASSERT_TRUE(RunScript("permissionState()", &script_result)); 567 ASSERT_TRUE(RunScript("permissionState()", &script_result));
568 EXPECT_EQ("permission status - granted", script_result); 568 EXPECT_EQ("permission status - granted", script_result);
569 } 569 }
570 #endif 570 #endif
571 571
572 IN_PROC_BROWSER_TEST_F(PushMessagingBrowserTest, PermissionStateSaysDefault) { 572 IN_PROC_BROWSER_TEST_F(PushMessagingBrowserTest, PermissionStateSaysPrompt) {
573 std::string script_result; 573 std::string script_result;
574 574
575 ASSERT_TRUE(RunScript("registerServiceWorker()", &script_result)); 575 ASSERT_TRUE(RunScript("registerServiceWorker()", &script_result));
576 ASSERT_EQ("ok - service worker registered", script_result); 576 ASSERT_EQ("ok - service worker registered", script_result);
577 577
578 ASSERT_TRUE(RunScript("permissionState()", &script_result)); 578 ASSERT_TRUE(RunScript("permissionState()", &script_result));
579 ASSERT_EQ("permission status - default", script_result); 579 ASSERT_EQ("permission status - prompt", script_result);
580 } 580 }
581 581
582 IN_PROC_BROWSER_TEST_F(PushMessagingBrowserTest, PermissionStateSaysGranted) { 582 IN_PROC_BROWSER_TEST_F(PushMessagingBrowserTest, PermissionStateSaysGranted) {
583 std::string script_result; 583 std::string script_result;
584 584
585 ASSERT_TRUE(RunScript("registerServiceWorker()", &script_result)); 585 ASSERT_TRUE(RunScript("registerServiceWorker()", &script_result));
586 ASSERT_EQ("ok - service worker registered", script_result); 586 ASSERT_EQ("ok - service worker registered", script_result);
587 587
588 InfoBarResponder accepting_responder(GetInfoBarService(), true); 588 InfoBarResponder accepting_responder(GetInfoBarService(), true);
589 ASSERT_TRUE(RunScript("requestNotificationPermission();", &script_result)); 589 ASSERT_TRUE(RunScript("requestNotificationPermission();", &script_result));
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after
674 new content::MessageLoopRunner; 674 new content::MessageLoopRunner;
675 push_service()->SetContentSettingChangedCallbackForTesting( 675 push_service()->SetContentSettingChangedCallbackForTesting(
676 message_loop_runner->QuitClosure()); 676 message_loop_runner->QuitClosure());
677 677
678 GetBrowser()->profile()->GetHostContentSettingsMap()-> 678 GetBrowser()->profile()->GetHostContentSettingsMap()->
679 ClearSettingsForOneType(CONTENT_SETTINGS_TYPE_PUSH_MESSAGING); 679 ClearSettingsForOneType(CONTENT_SETTINGS_TYPE_PUSH_MESSAGING);
680 680
681 message_loop_runner->Run(); 681 message_loop_runner->Run();
682 682
683 ASSERT_TRUE(RunScript("permissionState()", &script_result)); 683 ASSERT_TRUE(RunScript("permissionState()", &script_result));
684 EXPECT_EQ("permission status - default", script_result); 684 EXPECT_EQ("permission status - prompt", script_result);
685 685
686 ASSERT_TRUE(RunScript("hasSubscription()", &script_result)); 686 ASSERT_TRUE(RunScript("hasSubscription()", &script_result));
687 EXPECT_EQ("false - not subscribed", script_result); 687 EXPECT_EQ("false - not subscribed", script_result);
688 } 688 }
689 689
690 IN_PROC_BROWSER_TEST_F(PushMessagingBrowserTest, 690 IN_PROC_BROWSER_TEST_F(PushMessagingBrowserTest,
691 LocalResetPushPermissionUnsubscribes) { 691 LocalResetPushPermissionUnsubscribes) {
692 std::string script_result; 692 std::string script_result;
693 693
694 TryToSubscribeSuccessfully("1-0" /* expected_push_subscription_id */); 694 TryToSubscribeSuccessfully("1-0" /* expected_push_subscription_id */);
(...skipping 13 matching lines...) Expand all
708 GetBrowser()->profile()->GetHostContentSettingsMap()->SetContentSetting( 708 GetBrowser()->profile()->GetHostContentSettingsMap()->SetContentSetting(
709 ContentSettingsPattern::FromURLNoWildcard(origin), 709 ContentSettingsPattern::FromURLNoWildcard(origin),
710 ContentSettingsPattern::FromURLNoWildcard(origin), 710 ContentSettingsPattern::FromURLNoWildcard(origin),
711 CONTENT_SETTINGS_TYPE_PUSH_MESSAGING, 711 CONTENT_SETTINGS_TYPE_PUSH_MESSAGING,
712 std::string(), 712 std::string(),
713 CONTENT_SETTING_DEFAULT); 713 CONTENT_SETTING_DEFAULT);
714 714
715 message_loop_runner->Run(); 715 message_loop_runner->Run();
716 716
717 ASSERT_TRUE(RunScript("permissionState()", &script_result)); 717 ASSERT_TRUE(RunScript("permissionState()", &script_result));
718 EXPECT_EQ("permission status - default", script_result); 718 EXPECT_EQ("permission status - prompt", script_result);
719 719
720 ASSERT_TRUE(RunScript("hasSubscription()", &script_result)); 720 ASSERT_TRUE(RunScript("hasSubscription()", &script_result));
721 EXPECT_EQ("false - not subscribed", script_result); 721 EXPECT_EQ("false - not subscribed", script_result);
722 } 722 }
723 723
724 IN_PROC_BROWSER_TEST_F(PushMessagingBrowserTest, 724 IN_PROC_BROWSER_TEST_F(PushMessagingBrowserTest,
725 DenyPushPermissionUnsubscribes) { 725 DenyPushPermissionUnsubscribes) {
726 std::string script_result; 726 std::string script_result;
727 727
728 TryToSubscribeSuccessfully("1-0" /* expected_push_subscription_id */); 728 TryToSubscribeSuccessfully("1-0" /* expected_push_subscription_id */);
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
771 new content::MessageLoopRunner; 771 new content::MessageLoopRunner;
772 push_service()->SetContentSettingChangedCallbackForTesting( 772 push_service()->SetContentSettingChangedCallbackForTesting(
773 message_loop_runner->QuitClosure()); 773 message_loop_runner->QuitClosure());
774 774
775 GetBrowser()->profile()->GetHostContentSettingsMap()-> 775 GetBrowser()->profile()->GetHostContentSettingsMap()->
776 ClearSettingsForOneType(CONTENT_SETTINGS_TYPE_NOTIFICATIONS); 776 ClearSettingsForOneType(CONTENT_SETTINGS_TYPE_NOTIFICATIONS);
777 777
778 message_loop_runner->Run(); 778 message_loop_runner->Run();
779 779
780 ASSERT_TRUE(RunScript("permissionState()", &script_result)); 780 ASSERT_TRUE(RunScript("permissionState()", &script_result));
781 EXPECT_EQ("permission status - default", script_result); 781 EXPECT_EQ("permission status - prompt", script_result);
782 782
783 ASSERT_TRUE(RunScript("hasSubscription()", &script_result)); 783 ASSERT_TRUE(RunScript("hasSubscription()", &script_result));
784 EXPECT_EQ("false - not subscribed", script_result); 784 EXPECT_EQ("false - not subscribed", script_result);
785 } 785 }
786 786
787 IN_PROC_BROWSER_TEST_F(PushMessagingBrowserTest, 787 IN_PROC_BROWSER_TEST_F(PushMessagingBrowserTest,
788 LocalResetNotificationsPermissionUnsubscribes) { 788 LocalResetNotificationsPermissionUnsubscribes) {
789 std::string script_result; 789 std::string script_result;
790 790
791 TryToSubscribeSuccessfully("1-0" /* expected_push_subscription_id */); 791 TryToSubscribeSuccessfully("1-0" /* expected_push_subscription_id */);
(...skipping 13 matching lines...) Expand all
805 GetBrowser()->profile()->GetHostContentSettingsMap()->SetContentSetting( 805 GetBrowser()->profile()->GetHostContentSettingsMap()->SetContentSetting(
806 ContentSettingsPattern::FromURLNoWildcard(origin), 806 ContentSettingsPattern::FromURLNoWildcard(origin),
807 ContentSettingsPattern::Wildcard(), 807 ContentSettingsPattern::Wildcard(),
808 CONTENT_SETTINGS_TYPE_NOTIFICATIONS, 808 CONTENT_SETTINGS_TYPE_NOTIFICATIONS,
809 std::string(), 809 std::string(),
810 CONTENT_SETTING_DEFAULT); 810 CONTENT_SETTING_DEFAULT);
811 811
812 message_loop_runner->Run(); 812 message_loop_runner->Run();
813 813
814 ASSERT_TRUE(RunScript("permissionState()", &script_result)); 814 ASSERT_TRUE(RunScript("permissionState()", &script_result));
815 EXPECT_EQ("permission status - default", script_result); 815 EXPECT_EQ("permission status - prompt", script_result);
816 816
817 ASSERT_TRUE(RunScript("hasSubscription()", &script_result)); 817 ASSERT_TRUE(RunScript("hasSubscription()", &script_result));
818 EXPECT_EQ("false - not subscribed", script_result); 818 EXPECT_EQ("false - not subscribed", script_result);
819 } 819 }
820 820
821 IN_PROC_BROWSER_TEST_F(PushMessagingBrowserTest, 821 IN_PROC_BROWSER_TEST_F(PushMessagingBrowserTest,
822 DenyNotificationsPermissionUnsubscribes) { 822 DenyNotificationsPermissionUnsubscribes) {
823 std::string script_result; 823 std::string script_result;
824 824
825 TryToSubscribeSuccessfully("1-0" /* expected_push_subscription_id */); 825 TryToSubscribeSuccessfully("1-0" /* expected_push_subscription_id */);
(...skipping 192 matching lines...) Expand 10 before | Expand all | Expand 10 after
1018 std::string script_result; 1018 std::string script_result;
1019 1019
1020 ASSERT_TRUE(RunScript("registerServiceWorker()", &script_result)); 1020 ASSERT_TRUE(RunScript("registerServiceWorker()", &script_result));
1021 ASSERT_EQ("ok - service worker registered", script_result); 1021 ASSERT_EQ("ok - service worker registered", script_result);
1022 1022
1023 // In Incognito mode the promise returned by getSubscription should not hang, 1023 // In Incognito mode the promise returned by getSubscription should not hang,
1024 // it should just fulfill with null. 1024 // it should just fulfill with null.
1025 ASSERT_TRUE(RunScript("hasSubscription()", &script_result)); 1025 ASSERT_TRUE(RunScript("hasSubscription()", &script_result));
1026 ASSERT_EQ("false - not subscribed", script_result); 1026 ASSERT_EQ("false - not subscribed", script_result);
1027 } 1027 }
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/push_messaging/push_messaging_service_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698