| OLD | NEW |
| 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/renderer_host/render_view_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 MockRenderViewHostDelegate : public RenderViewHostDelegate { | 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 | |
| 28 // Stubs for pure virtual methods we don't care about. | |
| 29 virtual gfx::Rect GetRootWindowResizerRect() const OVERRIDE { | |
| 30 NOTREACHED(); | |
| 31 return gfx::Rect(); | |
| 32 } | |
| 33 virtual RendererPreferences GetRendererPrefs( | |
| 34 BrowserContext* browser_context) const OVERRIDE { | |
| 35 NOTREACHED(); | |
| 36 return RendererPreferences(); | |
| 37 } | |
| 38 }; | 27 }; |
| 39 | 28 |
| 40 class MockResponseCallback { | 29 class MockResponseCallback { |
| 41 public: | 30 public: |
| 42 MOCK_METHOD2(OnAccessRequestResponse, | 31 MOCK_METHOD2(OnAccessRequestResponse, |
| 43 void(const MediaStreamDevices& devices, | 32 void(const MediaStreamDevices& devices, |
| 44 content::MediaStreamRequestResult result)); | 33 content::MediaStreamRequestResult result)); |
| 45 }; | 34 }; |
| 46 | 35 |
| 47 class MockMediaStreamUI : public MediaStreamUI { | 36 class MockMediaStreamUI : public MediaStreamUI { |
| (...skipping 21 matching lines...) Expand all Loading... |
| 69 virtual ~MediaStreamUIProxyTest() { | 58 virtual ~MediaStreamUIProxyTest() { |
| 70 proxy_.reset(); | 59 proxy_.reset(); |
| 71 message_loop_.RunUntilIdle(); | 60 message_loop_.RunUntilIdle(); |
| 72 } | 61 } |
| 73 | 62 |
| 74 protected: | 63 protected: |
| 75 base::MessageLoop message_loop_; | 64 base::MessageLoop message_loop_; |
| 76 TestBrowserThread ui_thread_; | 65 TestBrowserThread ui_thread_; |
| 77 TestBrowserThread io_thread_; | 66 TestBrowserThread io_thread_; |
| 78 | 67 |
| 79 MockRenderViewHostDelegate delegate_; | 68 MockRenderFrameHostDelegate delegate_; |
| 80 MockResponseCallback response_callback_; | 69 MockResponseCallback response_callback_; |
| 81 scoped_ptr<MediaStreamUIProxy> proxy_; | 70 scoped_ptr<MediaStreamUIProxy> proxy_; |
| 82 }; | 71 }; |
| 83 | 72 |
| 84 MATCHER_P(SameRequest, expected, "") { | 73 MATCHER_P(SameRequest, expected, "") { |
| 85 return | 74 return |
| 86 expected.render_process_id == arg.render_process_id && | 75 expected.render_process_id == arg.render_process_id && |
| 87 expected.render_view_id == arg.render_view_id && | 76 expected.render_frame_id == arg.render_frame_id && |
| 88 expected.tab_capture_device_id == arg.tab_capture_device_id && | 77 expected.tab_capture_device_id == arg.tab_capture_device_id && |
| 89 expected.security_origin == arg.security_origin && | 78 expected.security_origin == arg.security_origin && |
| 90 expected.request_type == arg.request_type && | 79 expected.request_type == arg.request_type && |
| 91 expected.requested_audio_device_id == arg.requested_audio_device_id && | 80 expected.requested_audio_device_id == arg.requested_audio_device_id && |
| 92 expected.requested_video_device_id == arg.requested_video_device_id && | 81 expected.requested_video_device_id == arg.requested_video_device_id && |
| 93 expected.audio_type == arg.audio_type && | 82 expected.audio_type == arg.audio_type && |
| 94 expected.video_type == arg.video_type; | 83 expected.video_type == arg.video_type; |
| 95 } | 84 } |
| 96 | 85 |
| 97 TEST_F(MediaStreamUIProxyTest, Deny) { | 86 TEST_F(MediaStreamUIProxyTest, Deny) { |
| (...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 252 EXPECT_CALL(handler, OnWindowId(kWindowId)); | 241 EXPECT_CALL(handler, OnWindowId(kWindowId)); |
| 253 | 242 |
| 254 proxy_->OnStarted( | 243 proxy_->OnStarted( |
| 255 base::Bind(&MockStopStreamHandler::OnStop, base::Unretained(&handler)), | 244 base::Bind(&MockStopStreamHandler::OnStop, base::Unretained(&handler)), |
| 256 base::Bind(&MockStopStreamHandler::OnWindowId, | 245 base::Bind(&MockStopStreamHandler::OnWindowId, |
| 257 base::Unretained(&handler))); | 246 base::Unretained(&handler))); |
| 258 message_loop_.RunUntilIdle(); | 247 message_loop_.RunUntilIdle(); |
| 259 } | 248 } |
| 260 | 249 |
| 261 } // content | 250 } // content |
| OLD | NEW |