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

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

Issue 2910843002: [Cleanup] Move all browsertests to use ScopedFeatureList to modify features
Patch Set: Ilya comments addressed Created 3 years, 5 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
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 <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 126 matching lines...) Expand 10 before | Expand all | Expand 10 after
137 // The test server has a base directory that doesn't exist in the 137 // The test server has a base directory that doesn't exist in the
138 // filesystem. 138 // filesystem.
139 test_page_url_(std::string("/") + kTestFileName) {} 139 test_page_url_(std::string("/") + kTestFileName) {}
140 140
141 void PlatformNotificationServiceBrowserTest::SetUpDefaultCommandLine( 141 void PlatformNotificationServiceBrowserTest::SetUpDefaultCommandLine(
142 base::CommandLine* command_line) { 142 base::CommandLine* command_line) {
143 InProcessBrowserTest::SetUpDefaultCommandLine(command_line); 143 InProcessBrowserTest::SetUpDefaultCommandLine(command_line);
144 144
145 // Needed for the Reply button tests 145 // Needed for the Reply button tests
146 command_line->AppendSwitch(switches::kEnableExperimentalWebPlatformFeatures); 146 command_line->AppendSwitch(switches::kEnableExperimentalWebPlatformFeatures);
147
148 #if BUILDFLAG(ENABLE_NATIVE_NOTIFICATIONS)
149 // TODO(crbug.com/714679): Temporary change while tests are upgraded to deal
150 // with native notifications.
151 command_line->AppendSwitchASCII(switches::kDisableFeatures,
152 features::kNativeNotifications.name);
153 #endif // BUILDFLAG(ENABLE_NATIVE_NOTIFICATIONS)
154 } 147 }
155 148
156 void PlatformNotificationServiceBrowserTest::SetUp() { 149 void PlatformNotificationServiceBrowserTest::SetUp() {
157 ui_manager_.reset(new StubNotificationUIManager); 150 ui_manager_.reset(new StubNotificationUIManager);
158 https_server_.reset( 151 https_server_.reset(
159 new net::EmbeddedTestServer(net::EmbeddedTestServer::TYPE_HTTPS)); 152 new net::EmbeddedTestServer(net::EmbeddedTestServer::TYPE_HTTPS));
160 https_server_->ServeFilesFromSourceDirectory(server_root_); 153 https_server_->ServeFilesFromSourceDirectory(server_root_);
161 ASSERT_TRUE(https_server_->Start()); 154 ASSERT_TRUE(https_server_->Start());
155 #if BUILDFLAG(ENABLE_NATIVE_NOTIFICATIONS)
156 // TODO(crbug.com/714679): Temporary change while tests are upgraded to deal
157 // with native notifications.
158 feature_list_.InitAndDisableFeature(features::kNativeNotifications);
159 #endif // BUILDFLAG(ENABLE_NATIVE_NOTIFICATIONS)
162 InProcessBrowserTest::SetUp(); 160 InProcessBrowserTest::SetUp();
163 } 161 }
164 162
165 void PlatformNotificationServiceBrowserTest::SetUpOnMainThread() { 163 void PlatformNotificationServiceBrowserTest::SetUpOnMainThread() {
166 SiteEngagementScore::SetParamValuesForTesting(); 164 SiteEngagementScore::SetParamValuesForTesting();
167 engagement_service_ = SiteEngagementService::Get(browser()->profile()); 165 engagement_service_ = SiteEngagementService::Get(browser()->profile());
168 NavigateToTestPage(test_page_url_); 166 NavigateToTestPage(test_page_url_);
169 display_service_.reset( 167 display_service_.reset(
170 new MessageCenterDisplayService(browser()->profile(), ui_manager_.get())); 168 new MessageCenterDisplayService(browser()->profile(), ui_manager_.get()));
171 service()->SetNotificationDisplayServiceForTesting(display_service_.get()); 169 service()->SetNotificationDisplayServiceForTesting(display_service_.get());
(...skipping 649 matching lines...) Expand 10 before | Expand all | Expand 10 after
821 819
822 ASSERT_EQ(1u, ui_manager()->GetNotificationCount()); 820 ASSERT_EQ(1u, ui_manager()->GetNotificationCount());
823 const Notification& notification = ui_manager()->GetNotificationAt(0); 821 const Notification& notification = ui_manager()->GetNotificationAt(0);
824 EXPECT_FALSE(notification.delegate()->ShouldDisplayOverFullscreen()); 822 EXPECT_FALSE(notification.delegate()->ShouldDisplayOverFullscreen());
825 } 823 }
826 #endif 824 #endif
827 825
828 class PlatformNotificationServiceWithoutContentImageBrowserTest 826 class PlatformNotificationServiceWithoutContentImageBrowserTest
829 : public PlatformNotificationServiceBrowserTest { 827 : public PlatformNotificationServiceBrowserTest {
830 public: 828 public:
831 // InProcessBrowserTest overrides. 829 void SetUp() override {
832 void SetUpInProcessBrowserTestFixture() override { 830 scoped_feature_list_.InitAndDisableFeature(
833 #if BUILDFLAG(ENABLE_NATIVE_NOTIFICATIONS) 831 features::kNotificationContentImage);
834 scoped_feature_list_.InitWithFeatures( 832 PlatformNotificationServiceBrowserTest::SetUp();
835 {},
836 {features::kNotificationContentImage, features::kNativeNotifications});
837 #else
838 scoped_feature_list_.InitWithFeatures(
839 {}, {features::kNotificationContentImage});
840 #endif // BUILDFLAG(ENABLE_NATIVE_NOTIFICATIONS)
841 InProcessBrowserTest::SetUpInProcessBrowserTestFixture();
842 } 833 }
843 834
844 private: 835 private:
845 base::test::ScopedFeatureList scoped_feature_list_; 836 base::test::ScopedFeatureList scoped_feature_list_;
846 }; 837 };
847 838
848 IN_PROC_BROWSER_TEST_F( 839 IN_PROC_BROWSER_TEST_F(
849 PlatformNotificationServiceWithoutContentImageBrowserTest, 840 PlatformNotificationServiceWithoutContentImageBrowserTest,
850 KillSwitch) { 841 KillSwitch) {
851 ASSERT_NO_FATAL_FAILURE(GrantNotificationPermissionForTest()); 842 ASSERT_NO_FATAL_FAILURE(GrantNotificationPermissionForTest());
852 843
853 std::string script_result; 844 std::string script_result;
854 ASSERT_TRUE( 845 ASSERT_TRUE(
855 RunScript("DisplayPersistentAllOptionsNotification()", &script_result)); 846 RunScript("DisplayPersistentAllOptionsNotification()", &script_result));
856 EXPECT_EQ("ok", script_result); 847 EXPECT_EQ("ok", script_result);
857 848
858 ASSERT_EQ(1u, ui_manager()->GetNotificationCount()); 849 ASSERT_EQ(1u, ui_manager()->GetNotificationCount());
859 const Notification& notification = ui_manager()->GetNotificationAt(0); 850 const Notification& notification = ui_manager()->GetNotificationAt(0);
860 851
861 // Since the kNotificationContentImage kill switch has disabled images, the 852 // Since the kNotificationContentImage kill switch has disabled images, the
862 // notification should be shown without an image. 853 // notification should be shown without an image.
863 EXPECT_TRUE(notification.image().IsEmpty()); 854 EXPECT_TRUE(notification.image().IsEmpty());
864 } 855 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698