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

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

Issue 324143002: Decouple IPC::MessageFilter from IPC::Channel (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fixing compilation errors Created 6 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 <string> 5 #include <string>
6 #include <queue> 6 #include <queue>
7 7
8 #include "base/bind.h" 8 #include "base/bind.h"
9 #include "base/callback_helpers.h" 9 #include "base/callback_helpers.h"
10 #include "base/command_line.h" 10 #include "base/command_line.h"
(...skipping 245 matching lines...) Expand 10 before | Expand all | Expand 10 after
256 virtual void SetUp() OVERRIDE { 256 virtual void SetUp() OVERRIDE {
257 video_capture_device_factory_->GetDeviceNames(&physical_video_devices_); 257 video_capture_device_factory_->GetDeviceNames(&physical_video_devices_);
258 ASSERT_GT(physical_video_devices_.size(), 0u); 258 ASSERT_GT(physical_video_devices_.size(), 0u);
259 259
260 media_stream_manager_->audio_input_device_manager()->GetFakeDeviceNames( 260 media_stream_manager_->audio_input_device_manager()->GetFakeDeviceNames(
261 &physical_audio_devices_); 261 &physical_audio_devices_);
262 ASSERT_GT(physical_audio_devices_.size(), 0u); 262 ASSERT_GT(physical_audio_devices_.size(), 0u);
263 } 263 }
264 264
265 virtual void TearDown() OVERRIDE { 265 virtual void TearDown() OVERRIDE {
266 host_->OnChannelClosing(); 266 host_->OnSenderClosing();
267 } 267 }
268 268
269 protected: 269 protected:
270 virtual void SetupFakeUI(bool expect_started) { 270 virtual void SetupFakeUI(bool expect_started) {
271 scoped_ptr<MockMediaStreamUIProxy> stream_ui(new MockMediaStreamUIProxy()); 271 scoped_ptr<MockMediaStreamUIProxy> stream_ui(new MockMediaStreamUIProxy());
272 if (expect_started) { 272 if (expect_started) {
273 EXPECT_CALL(*stream_ui, OnStarted(_, _)); 273 EXPECT_CALL(*stream_ui, OnStarted(_, _));
274 } 274 }
275 media_stream_manager_->UseFakeUI( 275 media_stream_manager_->UseFakeUI(
276 stream_ui.PassAs<FakeMediaStreamUIProxy>()); 276 stream_ui.PassAs<FakeMediaStreamUIProxy>());
(...skipping 520 matching lines...) Expand 10 before | Expand all | Expand 10 after
797 run_loop1.QuitClosure()); 797 run_loop1.QuitClosure());
798 798
799 // Stop the video stream device from stream 1 while waiting for the 799 // Stop the video stream device from stream 1 while waiting for the
800 // second stream to be generated. 800 // second stream to be generated.
801 host_->OnStopStreamDevice(kRenderId, host_->video_devices_[0].device.id); 801 host_->OnStopStreamDevice(kRenderId, host_->video_devices_[0].device.id);
802 run_loop1.Run(); 802 run_loop1.Run();
803 803
804 EXPECT_EQ(host_->video_devices_.size(), 1u); 804 EXPECT_EQ(host_->video_devices_.size(), 1u);
805 } 805 }
806 806
807 TEST_F(MediaStreamDispatcherHostTest, CancelPendingStreamsOnChannelClosing) { 807 TEST_F(MediaStreamDispatcherHostTest, CancelPendingStreamsOnSenderClosing) {
808 StreamOptions options(false, true); 808 StreamOptions options(false, true);
809 809
810 base::RunLoop run_loop; 810 base::RunLoop run_loop;
811 811
812 // Create multiple GenerateStream requests. 812 // Create multiple GenerateStream requests.
813 size_t streams = 5; 813 size_t streams = 5;
814 for (size_t i = 1; i <= streams; ++i) { 814 for (size_t i = 1; i <= streams; ++i) {
815 host_->OnGenerateStream(kRenderId, kPageRequestId + i, options, origin_, 815 host_->OnGenerateStream(kRenderId, kPageRequestId + i, options, origin_,
816 run_loop.QuitClosure()); 816 run_loop.QuitClosure());
817 } 817 }
818 818
819 // Calling OnChannelClosing() to cancel all the pending requests. 819 // Calling OnSenderClosing() to cancel all the pending requests.
820 host_->OnChannelClosing(); 820 host_->OnSenderClosing();
821 run_loop.RunUntilIdle(); 821 run_loop.RunUntilIdle();
822 } 822 }
823 823
824 TEST_F(MediaStreamDispatcherHostTest, StopGeneratedStreamsOnChannelClosing) { 824 TEST_F(MediaStreamDispatcherHostTest, StopGeneratedStreamsOnSenderClosing) {
825 StreamOptions options(false, true); 825 StreamOptions options(false, true);
826 826
827 // Create first group of streams. 827 // Create first group of streams.
828 size_t generated_streams = 3; 828 size_t generated_streams = 3;
829 for (size_t i = 0; i < generated_streams; ++i) { 829 for (size_t i = 0; i < generated_streams; ++i) {
830 SetupFakeUI(true); 830 SetupFakeUI(true);
831 GenerateStreamAndWaitForResult(kRenderId, kPageRequestId + i, options); 831 GenerateStreamAndWaitForResult(kRenderId, kPageRequestId + i, options);
832 } 832 }
833 833
834 // Calling OnChannelClosing() to cancel all the pending/generated streams. 834 // Calling OnSenderClosing() to cancel all the pending/generated streams.
835 host_->OnChannelClosing(); 835 host_->OnSenderClosing();
836 base::RunLoop().RunUntilIdle(); 836 base::RunLoop().RunUntilIdle();
837 } 837 }
838 838
839 TEST_F(MediaStreamDispatcherHostTest, CloseFromUI) { 839 TEST_F(MediaStreamDispatcherHostTest, CloseFromUI) {
840 StreamOptions options(false, true); 840 StreamOptions options(false, true);
841 841
842 base::Closure close_callback; 842 base::Closure close_callback;
843 scoped_ptr<MockMediaStreamUIProxy> stream_ui(new MockMediaStreamUIProxy()); 843 scoped_ptr<MockMediaStreamUIProxy> stream_ui(new MockMediaStreamUIProxy());
844 EXPECT_CALL(*stream_ui, OnStarted(_, _)) 844 EXPECT_CALL(*stream_ui, OnStarted(_, _))
845 .WillOnce(SaveArg<0>(&close_callback)); 845 .WillOnce(SaveArg<0>(&close_callback));
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
900 TEST_F(MediaStreamDispatcherHostTest, EnumerateVideoDevicesNoAccess) { 900 TEST_F(MediaStreamDispatcherHostTest, EnumerateVideoDevicesNoAccess) {
901 MockResourceContext* mock_resource_context = 901 MockResourceContext* mock_resource_context =
902 static_cast<MockResourceContext*>(browser_context_.GetResourceContext()); 902 static_cast<MockResourceContext*>(browser_context_.GetResourceContext());
903 mock_resource_context->set_camera_access(false); 903 mock_resource_context->set_camera_access(false);
904 EnumerateDevicesAndWaitForResult(kRenderId, kPageRequestId, 904 EnumerateDevicesAndWaitForResult(kRenderId, kPageRequestId,
905 MEDIA_DEVICE_VIDEO_CAPTURE); 905 MEDIA_DEVICE_VIDEO_CAPTURE);
906 EXPECT_TRUE(DoesNotContainLabels(host_->enumerated_devices_)); 906 EXPECT_TRUE(DoesNotContainLabels(host_->enumerated_devices_));
907 } 907 }
908 908
909 }; // namespace content 909 }; // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698