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

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

Issue 1686903002: [Abandoned] Rename PermissionBubbleManager to PermissionRequestManager. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: tests compile Created 4 years, 8 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/files/file_path.h" 10 #include "base/files/file_path.h"
11 #include "base/path_service.h" 11 #include "base/path_service.h"
12 #include "base/strings/utf_string_conversions.h" 12 #include "base/strings/utf_string_conversions.h"
13 #include "base/time/time.h" 13 #include "base/time/time.h"
14 #include "chrome/browser/notifications/desktop_notification_profile_util.h" 14 #include "chrome/browser/notifications/desktop_notification_profile_util.h"
15 #include "chrome/browser/notifications/message_center_display_service.h" 15 #include "chrome/browser/notifications/message_center_display_service.h"
16 #include "chrome/browser/notifications/notification.h" 16 #include "chrome/browser/notifications/notification.h"
17 #include "chrome/browser/notifications/notification_test_util.h" 17 #include "chrome/browser/notifications/notification_test_util.h"
18 #include "chrome/browser/notifications/platform_notification_service_impl.h" 18 #include "chrome/browser/notifications/platform_notification_service_impl.h"
19 #include "chrome/browser/permissions/permission_manager.h" 19 #include "chrome/browser/permissions/permission_manager.h"
20 #include "chrome/browser/permissions/permission_request_manager.h"
20 #include "chrome/browser/ui/browser.h" 21 #include "chrome/browser/ui/browser.h"
21 #include "chrome/browser/ui/tabs/tab_strip_model.h" 22 #include "chrome/browser/ui/tabs/tab_strip_model.h"
22 #include "chrome/browser/ui/website_settings/permission_bubble_manager.h"
23 #include "chrome/grit/generated_resources.h" 23 #include "chrome/grit/generated_resources.h"
24 #include "chrome/test/base/in_process_browser_test.h" 24 #include "chrome/test/base/in_process_browser_test.h"
25 #include "chrome/test/base/ui_test_utils.h" 25 #include "chrome/test/base/ui_test_utils.h"
26 #include "content/public/browser/permission_type.h" 26 #include "content/public/browser/permission_type.h"
27 #include "content/public/common/content_switches.h" 27 #include "content/public/common/content_switches.h"
28 #include "content/public/test/browser_test_utils.h" 28 #include "content/public/test/browser_test_utils.h"
29 #include "net/base/filename_util.h" 29 #include "net/base/filename_util.h"
30 #include "net/test/embedded_test_server/embedded_test_server.h" 30 #include "net/test/embedded_test_server/embedded_test_server.h"
31 #include "testing/gmock/include/gmock/gmock.h" 31 #include "testing/gmock/include/gmock/gmock.h"
32 #include "third_party/WebKit/public/platform/modules/permissions/permission_stat us.mojom.h" 32 #include "third_party/WebKit/public/platform/modules/permissions/permission_stat us.mojom.h"
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
79 79
80 // Executes |script| and stores the result as a string in |result|. A boolean 80 // Executes |script| and stores the result as a string in |result|. A boolean
81 // will be returned, indicating whether the script was executed successfully. 81 // will be returned, indicating whether the script was executed successfully.
82 bool RunScript(const std::string& script, std::string* result) const; 82 bool RunScript(const std::string& script, std::string* result) const;
83 83
84 net::HostPortPair ServerHostPort() const; 84 net::HostPortPair ServerHostPort() const;
85 GURL TestPageUrl() const; 85 GURL TestPageUrl() const;
86 86
87 private: 87 private:
88 std::string RequestAndRespondToPermission( 88 std::string RequestAndRespondToPermission(
89 PermissionBubbleManager::AutoResponseType bubble_response); 89 PermissionRequestManager::AutoResponseType response);
90 90
91 content::WebContents* GetActiveWebContents(Browser* browser) { 91 content::WebContents* GetActiveWebContents(Browser* browser) {
92 return browser->tab_strip_model()->GetActiveWebContents(); 92 return browser->tab_strip_model()->GetActiveWebContents();
93 } 93 }
94 94
95 const base::FilePath server_root_; 95 const base::FilePath server_root_;
96 const std::string test_page_url_; 96 const std::string test_page_url_;
97 std::unique_ptr<StubNotificationUIManager> ui_manager_; 97 std::unique_ptr<StubNotificationUIManager> ui_manager_;
98 std::unique_ptr<MessageCenterDisplayService> display_service_; 98 std::unique_ptr<MessageCenterDisplayService> display_service_;
99 std::unique_ptr<net::EmbeddedTestServer> https_server_; 99 std::unique_ptr<net::EmbeddedTestServer> https_server_;
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
166 const { 166 const {
167 return https_server_->host_port_pair(); 167 return https_server_->host_port_pair();
168 } 168 }
169 169
170 GURL PlatformNotificationServiceBrowserTest::TestPageUrl() const { 170 GURL PlatformNotificationServiceBrowserTest::TestPageUrl() const {
171 return https_server_->GetURL(test_page_url_); 171 return https_server_->GetURL(test_page_url_);
172 } 172 }
173 173
174 std::string 174 std::string
175 PlatformNotificationServiceBrowserTest::RequestAndRespondToPermission( 175 PlatformNotificationServiceBrowserTest::RequestAndRespondToPermission(
176 PermissionBubbleManager::AutoResponseType bubble_response) { 176 PermissionRequestManager::AutoResponseType response) {
177 std::string result; 177 std::string result;
178 content::WebContents* web_contents = GetActiveWebContents(browser()); 178 content::WebContents* web_contents = GetActiveWebContents(browser());
179 PermissionBubbleManager::FromWebContents(web_contents) 179 PermissionRequestManager::FromWebContents(web_contents)
180 ->set_auto_response_for_test(bubble_response); 180 ->set_auto_response_for_test(response);
181 EXPECT_TRUE(RunScript("RequestPermission();", &result)); 181 EXPECT_TRUE(RunScript("RequestPermission();", &result));
182 return result; 182 return result;
183 } 183 }
184 184
185 bool PlatformNotificationServiceBrowserTest::RequestAndAcceptPermission() { 185 bool PlatformNotificationServiceBrowserTest::RequestAndAcceptPermission() {
186 std::string result = 186 std::string result =
187 RequestAndRespondToPermission(PermissionBubbleManager::ACCEPT_ALL); 187 RequestAndRespondToPermission(PermissionRequestManager::ACCEPT_ALL);
188 return "granted" == result; 188 return "granted" == result;
189 } 189 }
190 190
191 bool PlatformNotificationServiceBrowserTest::RequestAndDenyPermission() { 191 bool PlatformNotificationServiceBrowserTest::RequestAndDenyPermission() {
192 std::string result = 192 std::string result =
193 RequestAndRespondToPermission(PermissionBubbleManager::DENY_ALL); 193 RequestAndRespondToPermission(PermissionRequestManager::DENY_ALL);
194 return "denied" == result; 194 return "denied" == result;
195 } 195 }
196 196
197 // ----------------------------------------------------------------------------- 197 // -----------------------------------------------------------------------------
198 198
199 // TODO(peter): Move PlatformNotificationService-related tests over from 199 // TODO(peter): Move PlatformNotificationService-related tests over from
200 // notification_browsertest.cc to this file. 200 // notification_browsertest.cc to this file.
201 201
202 IN_PROC_BROWSER_TEST_F(PlatformNotificationServiceBrowserTest, 202 IN_PROC_BROWSER_TEST_F(PlatformNotificationServiceBrowserTest,
203 DisplayPersistentNotificationWithoutPermission) { 203 DisplayPersistentNotificationWithoutPermission) {
(...skipping 287 matching lines...) Expand 10 before | Expand all | Expand 10 after
491 EXPECT_EQ("actionTitle2", base::UTF16ToUTF8(notification.buttons()[1].title)); 491 EXPECT_EQ("actionTitle2", base::UTF16ToUTF8(notification.buttons()[1].title));
492 492
493 notification.delegate()->ButtonClick(0); 493 notification.delegate()->ButtonClick(0);
494 ASSERT_TRUE(RunScript("GetMessageFromWorker()", &script_result)); 494 ASSERT_TRUE(RunScript("GetMessageFromWorker()", &script_result));
495 EXPECT_EQ("action_button_click actionId1", script_result); 495 EXPECT_EQ("action_button_click actionId1", script_result);
496 496
497 notification.delegate()->ButtonClick(1); 497 notification.delegate()->ButtonClick(1);
498 ASSERT_TRUE(RunScript("GetMessageFromWorker()", &script_result)); 498 ASSERT_TRUE(RunScript("GetMessageFromWorker()", &script_result));
499 EXPECT_EQ("action_button_click actionId2", script_result); 499 EXPECT_EQ("action_button_click actionId2", script_result);
500 } 500 }
OLDNEW
« no previous file with comments | « chrome/browser/media/webrtc_browsertest_base.cc ('k') | chrome/browser/permissions/permission_context_base.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698