OLD | NEW |
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 <memory> | 5 #include <memory> |
6 #include <string> | 6 #include <string> |
7 #include <vector> | 7 #include <vector> |
8 | 8 |
9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
10 #include "base/feature_list.h" | 10 #include "base/feature_list.h" |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
61 | 61 |
62 const int kNotificationVibrationPattern[] = { 100, 200, 300 }; | 62 const int kNotificationVibrationPattern[] = { 100, 200, 300 }; |
63 const double kNotificationTimestamp = 621046800000.; | 63 const double kNotificationTimestamp = 621046800000.; |
64 | 64 |
65 class PlatformNotificationServiceBrowserTest : public InProcessBrowserTest { | 65 class PlatformNotificationServiceBrowserTest : public InProcessBrowserTest { |
66 public: | 66 public: |
67 PlatformNotificationServiceBrowserTest(); | 67 PlatformNotificationServiceBrowserTest(); |
68 ~PlatformNotificationServiceBrowserTest() override {} | 68 ~PlatformNotificationServiceBrowserTest() override {} |
69 | 69 |
70 // InProcessBrowserTest overrides. | 70 // InProcessBrowserTest overrides. |
71 void SetUpCommandLine(base::CommandLine* command_line) override; | 71 void SetUpDefaultCommandLine(base::CommandLine* command_line) override; |
| 72 |
72 void SetUp() override; | 73 void SetUp() override; |
73 void SetUpOnMainThread() override; | 74 void SetUpOnMainThread() override; |
74 void TearDown() override; | 75 void TearDown() override; |
75 | 76 |
76 protected: | 77 protected: |
77 // Returns the Platform Notification Service these unit tests are for. | 78 // Returns the Platform Notification Service these unit tests are for. |
78 PlatformNotificationServiceImpl* service() const { | 79 PlatformNotificationServiceImpl* service() const { |
79 return PlatformNotificationServiceImpl::GetInstance(); | 80 return PlatformNotificationServiceImpl::GetInstance(); |
80 } | 81 } |
81 | 82 |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
129 namespace { | 130 namespace { |
130 const char kTestFileName[] = "notifications/platform_notification_service.html"; | 131 const char kTestFileName[] = "notifications/platform_notification_service.html"; |
131 } | 132 } |
132 | 133 |
133 PlatformNotificationServiceBrowserTest::PlatformNotificationServiceBrowserTest() | 134 PlatformNotificationServiceBrowserTest::PlatformNotificationServiceBrowserTest() |
134 : server_root_(FILE_PATH_LITERAL("chrome/test/data")), | 135 : server_root_(FILE_PATH_LITERAL("chrome/test/data")), |
135 // The test server has a base directory that doesn't exist in the | 136 // The test server has a base directory that doesn't exist in the |
136 // filesystem. | 137 // filesystem. |
137 test_page_url_(std::string("/") + kTestFileName) {} | 138 test_page_url_(std::string("/") + kTestFileName) {} |
138 | 139 |
139 void PlatformNotificationServiceBrowserTest::SetUpCommandLine( | 140 void PlatformNotificationServiceBrowserTest::SetUpDefaultCommandLine( |
140 base::CommandLine* command_line) { | 141 base::CommandLine* command_line) { |
| 142 InProcessBrowserTest::SetUpDefaultCommandLine(command_line); |
| 143 |
| 144 // Needed for the Reply button tests |
141 command_line->AppendSwitch(switches::kEnableExperimentalWebPlatformFeatures); | 145 command_line->AppendSwitch(switches::kEnableExperimentalWebPlatformFeatures); |
142 | 146 |
143 InProcessBrowserTest::SetUpCommandLine(command_line); | 147 #if BUILDFLAG(ENABLE_NATIVE_NOTIFICATIONS) |
| 148 // TODO(crbug.com/714679): Temporary change while tests are upgraded to deal |
| 149 // with native notifications. |
| 150 command_line->AppendSwitchASCII(switches::kDisableFeatures, |
| 151 features::kNativeNotifications.name); |
| 152 #endif // BUILDFLAG(ENABLE_NATIVE_NOTIFICATIONS) |
144 } | 153 } |
145 | 154 |
146 void PlatformNotificationServiceBrowserTest::SetUp() { | 155 void PlatformNotificationServiceBrowserTest::SetUp() { |
147 ui_manager_.reset(new StubNotificationUIManager); | 156 ui_manager_.reset(new StubNotificationUIManager); |
148 https_server_.reset( | 157 https_server_.reset( |
149 new net::EmbeddedTestServer(net::EmbeddedTestServer::TYPE_HTTPS)); | 158 new net::EmbeddedTestServer(net::EmbeddedTestServer::TYPE_HTTPS)); |
150 https_server_->ServeFilesFromSourceDirectory(server_root_); | 159 https_server_->ServeFilesFromSourceDirectory(server_root_); |
151 ASSERT_TRUE(https_server_->Start()); | 160 ASSERT_TRUE(https_server_->Start()); |
152 InProcessBrowserTest::SetUp(); | 161 InProcessBrowserTest::SetUp(); |
153 } | 162 } |
(...skipping 663 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
817 const Notification& notification = ui_manager()->GetNotificationAt(0); | 826 const Notification& notification = ui_manager()->GetNotificationAt(0); |
818 EXPECT_FALSE(notification.delegate()->ShouldDisplayOverFullscreen()); | 827 EXPECT_FALSE(notification.delegate()->ShouldDisplayOverFullscreen()); |
819 } | 828 } |
820 #endif | 829 #endif |
821 | 830 |
822 class PlatformNotificationServiceWithoutContentImageBrowserTest | 831 class PlatformNotificationServiceWithoutContentImageBrowserTest |
823 : public PlatformNotificationServiceBrowserTest { | 832 : public PlatformNotificationServiceBrowserTest { |
824 public: | 833 public: |
825 // InProcessBrowserTest overrides. | 834 // InProcessBrowserTest overrides. |
826 void SetUpInProcessBrowserTestFixture() override { | 835 void SetUpInProcessBrowserTestFixture() override { |
827 scoped_feature_list_.InitAndDisableFeature( | 836 #if BUILDFLAG(ENABLE_NATIVE_NOTIFICATIONS) |
828 features::kNotificationContentImage); | 837 scoped_feature_list_.InitWithFeatures( |
| 838 {}, |
| 839 {features::kNotificationContentImage, features::kNativeNotifications}); |
| 840 #else |
| 841 scoped_feature_list_.InitWithFeatures( |
| 842 {}, {features::kNotificationContentImage}); |
| 843 #endif // BUILDFLAG(ENABLE_NATIVE_NOTIFICATIONS) |
829 InProcessBrowserTest::SetUpInProcessBrowserTestFixture(); | 844 InProcessBrowserTest::SetUpInProcessBrowserTestFixture(); |
830 } | 845 } |
831 | 846 |
832 private: | 847 private: |
833 base::test::ScopedFeatureList scoped_feature_list_; | 848 base::test::ScopedFeatureList scoped_feature_list_; |
834 }; | 849 }; |
835 | 850 |
836 IN_PROC_BROWSER_TEST_F( | 851 IN_PROC_BROWSER_TEST_F( |
837 PlatformNotificationServiceWithoutContentImageBrowserTest, | 852 PlatformNotificationServiceWithoutContentImageBrowserTest, |
838 KillSwitch) { | 853 KillSwitch) { |
839 ASSERT_NO_FATAL_FAILURE(GrantNotificationPermissionForTest()); | 854 ASSERT_NO_FATAL_FAILURE(GrantNotificationPermissionForTest()); |
840 | 855 |
841 std::string script_result; | 856 std::string script_result; |
842 ASSERT_TRUE( | 857 ASSERT_TRUE( |
843 RunScript("DisplayPersistentAllOptionsNotification()", &script_result)); | 858 RunScript("DisplayPersistentAllOptionsNotification()", &script_result)); |
844 EXPECT_EQ("ok", script_result); | 859 EXPECT_EQ("ok", script_result); |
845 | 860 |
846 ASSERT_EQ(1u, ui_manager()->GetNotificationCount()); | 861 ASSERT_EQ(1u, ui_manager()->GetNotificationCount()); |
847 const Notification& notification = ui_manager()->GetNotificationAt(0); | 862 const Notification& notification = ui_manager()->GetNotificationAt(0); |
848 | 863 |
849 // Since the kNotificationContentImage kill switch has disabled images, the | 864 // Since the kNotificationContentImage kill switch has disabled images, the |
850 // notification should be shown without an image. | 865 // notification should be shown without an image. |
851 EXPECT_TRUE(notification.image().IsEmpty()); | 866 EXPECT_TRUE(notification.image().IsEmpty()); |
852 } | 867 } |
OLD | NEW |