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

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

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

Powered by Google App Engine
This is Rietveld 408576698