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

Unified Diff: chrome/browser/policy/policy_browsertest.cc

Issue 2711883003: Change MediaStreamDevicesController tests to use RequestPermissions function (Closed)
Patch Set: Add test delegate Created 3 years, 10 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/browser/media/webrtc/media_stream_devices_controller_browsertest.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/policy/policy_browsertest.cc
diff --git a/chrome/browser/policy/policy_browsertest.cc b/chrome/browser/policy/policy_browsertest.cc
index fda3b2834aef58014ce56fca207d95c960fd762a..dac29ebe472e83fc384adaad97db871fddcb69aa 100644
--- a/chrome/browser/policy/policy_browsertest.cc
+++ b/chrome/browser/policy/policy_browsertest.cc
@@ -63,6 +63,7 @@
#include "chrome/browser/metrics/variations/chrome_variations_service_client.h"
#include "chrome/browser/net/prediction_options.h"
#include "chrome/browser/net/url_request_mock_util.h"
+#include "chrome/browser/permissions/permission_request_manager.h"
#include "chrome/browser/policy/cloud/test_request_interceptor.h"
#include "chrome/browser/policy/profile_policy_connector.h"
#include "chrome/browser/policy/profile_policy_connector_factory.h"
@@ -3089,10 +3090,38 @@ class MediaStreamDevicesControllerBrowserTest
: public PolicyTest,
public testing::WithParamInterface<bool> {
public:
+ // TODO(raymes): When crbug.com/606138 is finished and the
+ // PermissionRequestManager is used to show all prompts on Android/Desktop
+ // we should remove PermissionPromptDelegate and just use
+ // MockPermissionPromptFactory instead. The APIs are the same.
+ class TestPermissionPromptDelegate
+ : public MediaStreamDevicesController::PermissionPromptDelegate {
+ public:
+ void ShowPrompt(
+ bool user_gesture,
+ content::WebContents* web_contents,
+ std::unique_ptr<MediaStreamDevicesController> controller) override {
+ if (response_type_ == PermissionRequestManager::ACCEPT_ALL)
+ controller->PermissionGranted();
+ else if (response_type_ == PermissionRequestManager::DENY_ALL)
+ controller->PermissionDenied();
+ }
+
+ void set_response_type(
+ PermissionRequestManager::AutoResponseType response_type) {
+ response_type_ = response_type;
+ }
+
+ private:
+ PermissionRequestManager::AutoResponseType response_type_ =
+ PermissionRequestManager::NONE;
+ };
+
MediaStreamDevicesControllerBrowserTest()
: request_url_allowed_via_whitelist_(false),
request_url_("https://www.example.com/foo") {
policy_value_ = GetParam();
+ prompt_delegate_.set_response_type(PermissionRequestManager::ACCEPT_ALL);
}
virtual ~MediaStreamDevicesControllerBrowserTest() {}
@@ -3146,12 +3175,11 @@ class MediaStreamDevicesControllerBrowserTest
content::MEDIA_NO_SERVICE, false);
// TODO(raymes): Test MEDIA_DEVICE_OPEN (Pepper) which grants both webcam
// and microphone permissions at the same time.
- MediaStreamDevicesController controller(
+ MediaStreamDevicesController::RequestPermissionsWithDelegate(
browser()->tab_strip_model()->GetActiveWebContents(), request,
base::Bind(&MediaStreamDevicesControllerBrowserTest::Accept,
- base::Unretained(this)));
- if (controller.IsAskingForAudio())
- controller.PermissionGranted();
+ base::Unretained(this)),
+ &prompt_delegate_);
base::MessageLoop::current()->QuitWhenIdle();
}
@@ -3163,16 +3191,16 @@ class MediaStreamDevicesControllerBrowserTest
content::MEDIA_DEVICE_VIDEO_CAPTURE, false);
// TODO(raymes): Test MEDIA_DEVICE_OPEN (Pepper) which grants both webcam
// and microphone permissions at the same time.
- MediaStreamDevicesController controller(
+ MediaStreamDevicesController::RequestPermissionsWithDelegate(
browser()->tab_strip_model()->GetActiveWebContents(), request,
base::Bind(&MediaStreamDevicesControllerBrowserTest::Accept,
- base::Unretained(this)));
- if (controller.IsAskingForVideo())
- controller.PermissionGranted();
+ base::Unretained(this)),
+ &prompt_delegate_);
base::MessageLoop::current()->QuitWhenIdle();
}
+ TestPermissionPromptDelegate prompt_delegate_;
bool policy_value_;
bool request_url_allowed_via_whitelist_;
GURL request_url_;
« no previous file with comments | « chrome/browser/media/webrtc/media_stream_devices_controller_browsertest.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698