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

Side by Side Diff: content/browser/renderer_host/media/media_stream_ui_proxy_unittest.cc

Issue 562263002: Check media permissions through RenderFrameHostDelegate. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@render_frame_get_sources
Patch Set: Rebase Created 6 years, 3 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 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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 "content/browser/renderer_host/media/media_stream_ui_proxy.h" 5 #include "content/browser/renderer_host/media/media_stream_ui_proxy.h"
6 6
7 #include "base/message_loop/message_loop.h" 7 #include "base/message_loop/message_loop.h"
8 #include "content/browser/frame_host/render_frame_host_delegate.h" 8 #include "content/browser/frame_host/render_frame_host_delegate.h"
9 #include "content/public/common/renderer_preferences.h" 9 #include "content/public/common/renderer_preferences.h"
10 #include "content/public/test/test_browser_thread.h" 10 #include "content/public/test/test_browser_thread.h"
11 #include "testing/gmock/include/gmock/gmock.h" 11 #include "testing/gmock/include/gmock/gmock.h"
12 #include "testing/gtest/include/gtest/gtest.h" 12 #include "testing/gtest/include/gtest/gtest.h"
13 #include "ui/gfx/rect.h" 13 #include "ui/gfx/rect.h"
14 14
15 using testing::_; 15 using testing::_;
16 using testing::Return; 16 using testing::Return;
17 using testing::SaveArg; 17 using testing::SaveArg;
18 18
19 namespace content { 19 namespace content {
20 namespace { 20 namespace {
21 21
22 class MockRenderFrameHostDelegate : public RenderFrameHostDelegate { 22 class MockRenderFrameHostDelegate : public RenderFrameHostDelegate {
23 public: 23 public:
24 MOCK_METHOD2(RequestMediaAccessPermission, 24 MOCK_METHOD2(RequestMediaAccessPermission,
25 void(const MediaStreamRequest& request, 25 void(const MediaStreamRequest& request,
26 const MediaResponseCallback& callback)); 26 const MediaResponseCallback& callback));
27 MOCK_METHOD2(CheckMediaAccessPermission,
28 bool(const GURL& security_origin,
29 MediaStreamType type));
27 }; 30 };
28 31
29 class MockResponseCallback { 32 class MockResponseCallback {
30 public: 33 public:
31 MOCK_METHOD2(OnAccessRequestResponse, 34 MOCK_METHOD2(OnAccessRequestResponse,
32 void(const MediaStreamDevices& devices, 35 void(const MediaStreamDevices& devices,
33 content::MediaStreamRequestResult result)); 36 content::MediaStreamRequestResult result));
37 MOCK_METHOD1(OnCheckResponse, void(bool have_access));
34 }; 38 };
35 39
36 class MockMediaStreamUI : public MediaStreamUI { 40 class MockMediaStreamUI : public MediaStreamUI {
37 public: 41 public:
38 MOCK_METHOD1(OnStarted, gfx::NativeViewId(const base::Closure& stop)); 42 MOCK_METHOD1(OnStarted, gfx::NativeViewId(const base::Closure& stop));
39 }; 43 };
40 44
41 class MockStopStreamHandler { 45 class MockStopStreamHandler {
42 public: 46 public:
43 MOCK_METHOD0(OnStop, void()); 47 MOCK_METHOD0(OnStop, void());
(...skipping 196 matching lines...) Expand 10 before | Expand all | Expand 10 after
240 MockStopStreamHandler handler; 244 MockStopStreamHandler handler;
241 EXPECT_CALL(handler, OnWindowId(kWindowId)); 245 EXPECT_CALL(handler, OnWindowId(kWindowId));
242 246
243 proxy_->OnStarted( 247 proxy_->OnStarted(
244 base::Bind(&MockStopStreamHandler::OnStop, base::Unretained(&handler)), 248 base::Bind(&MockStopStreamHandler::OnStop, base::Unretained(&handler)),
245 base::Bind(&MockStopStreamHandler::OnWindowId, 249 base::Bind(&MockStopStreamHandler::OnWindowId,
246 base::Unretained(&handler))); 250 base::Unretained(&handler)));
247 message_loop_.RunUntilIdle(); 251 message_loop_.RunUntilIdle();
248 } 252 }
249 253
254 TEST_F(MediaStreamUIProxyTest, CheckAccess) {
255 proxy_->CheckAccess(GURL("http://origin/"),
256 MEDIA_DEVICE_AUDIO_CAPTURE,
257 0,
258 0,
259 base::Bind(&MockResponseCallback::OnCheckResponse,
260 base::Unretained(&response_callback_)));
261 EXPECT_CALL(delegate_, CheckMediaAccessPermission(_, _));
262 EXPECT_CALL(response_callback_, OnCheckResponse(_));
263 message_loop_.RunUntilIdle();
264 }
265
250 } // content 266 } // content
OLDNEW
« no previous file with comments | « content/browser/renderer_host/media/media_stream_ui_proxy.cc ('k') | content/browser/web_contents/web_contents_impl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698