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

Side by Side Diff: content/renderer/media/mock_media_stream_dispatcher.cc

Issue 2550493003: Add new device ID unit tests to UserMediaClientImpl. (Closed)
Patch Set: hta@'s comments Created 4 years 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 (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 "content/renderer/media/mock_media_stream_dispatcher.h" 5 #include "content/renderer/media/mock_media_stream_dispatcher.h"
6 6
7 #include "base/strings/string_number_conversions.h" 7 #include "base/strings/string_number_conversions.h"
8 #include "content/public/common/media_stream_request.h" 8 #include "content/public/common/media_stream_request.h"
9 #include "media/base/audio_parameters.h" 9 #include "media/base/audio_parameters.h"
10 #include "testing/gtest/include/gtest/gtest.h" 10 #include "testing/gtest/include/gtest/gtest.h"
(...skipping 22 matching lines...) Expand all
33 const url::Origin& url) { 33 const url::Origin& url) {
34 // Audio and video share the same request so we use |audio_input_request_id_| 34 // Audio and video share the same request so we use |audio_input_request_id_|
35 // only. 35 // only.
36 audio_input_request_id_ = request_id; 36 audio_input_request_id_ = request_id;
37 37
38 stream_label_ = "local_stream" + base::IntToString(request_id); 38 stream_label_ = "local_stream" + base::IntToString(request_id);
39 audio_input_array_.clear(); 39 audio_input_array_.clear();
40 video_array_.clear(); 40 video_array_.clear();
41 41
42 if (controls.audio.requested) { 42 if (controls.audio.requested) {
43 AddAudioInputDeviceToArray(false); 43 AddAudioInputDeviceToArray(false, controls.audio.device_id);
44 } 44 }
45 if (controls.video.requested) { 45 if (controls.video.requested) {
46 AddVideoDeviceToArray(true); 46 AddVideoDeviceToArray(true, controls.video.device_id);
47 } 47 }
48 ++request_stream_counter_; 48 ++request_stream_counter_;
49 } 49 }
50 50
51 void MockMediaStreamDispatcher::CancelGenerateStream( 51 void MockMediaStreamDispatcher::CancelGenerateStream(
52 int request_id, 52 int request_id,
53 const base::WeakPtr<MediaStreamDispatcherEventHandler>& event_handler) { 53 const base::WeakPtr<MediaStreamDispatcherEventHandler>& event_handler) {
54 EXPECT_EQ(request_id, audio_input_request_id_); 54 EXPECT_EQ(request_id, audio_input_request_id_);
55 } 55 }
56 56
(...skipping 18 matching lines...) Expand all
75 int index) { 75 int index) {
76 return -1; 76 return -1;
77 } 77 }
78 78
79 int MockMediaStreamDispatcher::audio_session_id(const std::string& label, 79 int MockMediaStreamDispatcher::audio_session_id(const std::string& label,
80 int index) { 80 int index) {
81 return -1; 81 return -1;
82 } 82 }
83 83
84 void MockMediaStreamDispatcher::AddAudioInputDeviceToArray( 84 void MockMediaStreamDispatcher::AddAudioInputDeviceToArray(
85 bool matched_output) { 85 bool matched_output,
86 const std::string& device_id) {
86 StreamDeviceInfo audio; 87 StreamDeviceInfo audio;
87 audio.device.id = test_same_id_ ? "test_id" : "audio_input_device_id"; 88 audio.device.id = test_same_id_ ? "test_id" : device_id;
88 audio.device.id = audio.device.id + base::IntToString(session_id_); 89 audio.device.id = audio.device.id + base::IntToString(session_id_);
89 audio.device.name = "microphone"; 90 audio.device.name = "microphone";
90 audio.device.type = MEDIA_DEVICE_AUDIO_CAPTURE; 91 audio.device.type = MEDIA_DEVICE_AUDIO_CAPTURE;
91 audio.device.video_facing = MEDIA_VIDEO_FACING_NONE; 92 audio.device.video_facing = MEDIA_VIDEO_FACING_NONE;
92 if (matched_output) { 93 if (matched_output) {
93 audio.device.matched_output_device_id = 94 audio.device.matched_output_device_id =
94 kAudioOutputDeviceIdPrefix + base::IntToString(session_id_); 95 kAudioOutputDeviceIdPrefix + base::IntToString(session_id_);
95 } 96 }
96 audio.session_id = session_id_; 97 audio.session_id = session_id_;
97 audio.device.input.sample_rate = media::AudioParameters::kAudioCDSampleRate; 98 audio.device.input.sample_rate = media::AudioParameters::kAudioCDSampleRate;
98 audio.device.input.channel_layout = media::CHANNEL_LAYOUT_STEREO; 99 audio.device.input.channel_layout = media::CHANNEL_LAYOUT_STEREO;
99 audio.device.input.frames_per_buffer = audio.device.input.sample_rate / 100; 100 audio.device.input.frames_per_buffer = audio.device.input.sample_rate / 100;
100 audio_input_array_.push_back(audio); 101 audio_input_array_.push_back(audio);
101 } 102 }
102 103
103 void MockMediaStreamDispatcher::AddVideoDeviceToArray(bool facing_user) { 104 void MockMediaStreamDispatcher::AddVideoDeviceToArray(
105 bool facing_user,
106 const std::string& device_id) {
104 StreamDeviceInfo video; 107 StreamDeviceInfo video;
105 video.device.id = test_same_id_ ? "test_id" : "video_device_id"; 108 video.device.id = test_same_id_ ? "test_id" : device_id;
106 video.device.id = video.device.id + base::IntToString(session_id_); 109 video.device.id = video.device.id + base::IntToString(session_id_);
107 video.device.name = "usb video camera"; 110 video.device.name = "usb video camera";
108 video.device.type = MEDIA_DEVICE_VIDEO_CAPTURE; 111 video.device.type = MEDIA_DEVICE_VIDEO_CAPTURE;
109 video.device.video_facing = facing_user ? MEDIA_VIDEO_FACING_USER 112 video.device.video_facing = facing_user ? MEDIA_VIDEO_FACING_USER
110 : MEDIA_VIDEO_FACING_ENVIRONMENT; 113 : MEDIA_VIDEO_FACING_ENVIRONMENT;
111 video.session_id = session_id_; 114 video.session_id = session_id_;
112 video_array_.push_back(video); 115 video_array_.push_back(video);
113 } 116 }
114 117
115 } // namespace content 118 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698