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
3 // found in the LICENSE file.
5 #include "content/renderer/media/mock_media_stream_dispatcher.h"
7 #include "base/strings/stringprintf.h"
8 #include "content/public/common/media_stream_request.h"
9 #include "testing/gtest/include/gtest/gtest.h"
13 MockMediaStreamDispatcher::MockMediaStreamDispatcher()
14 : MediaStreamDispatcher(NULL),
16 request_stream_counter_(0),
17 stop_audio_device_counter_(0),
18 stop_video_device_counter_(0),
22 MockMediaStreamDispatcher::~MockMediaStreamDispatcher() {}
24 void MockMediaStreamDispatcher::GenerateStream(
26 const base::WeakPtr<MediaStreamDispatcherEventHandler>& event_handler,
27 const StreamOptions& components,
29 request_id_ = request_id;
31 stream_label_ = base::StringPrintf("%s%d","local_stream",request_id);
35 if (IsAudioMediaType(components.audio_type)) {
36 StreamDeviceInfo audio;
37 audio.device.id = "audio_device_id";
38 audio.device.name = "microphone";
39 audio.device.type = components.audio_type;
40 audio.session_id = session_id_;
41 audio_array_.push_back(audio);
43 if (IsVideoMediaType(components.video_type)) {
44 StreamDeviceInfo video;
45 video.device.id = "video_device_id";
46 video.device.name = "usb video camera";
47 video.device.type = components.video_type;
48 video.session_id = session_id_;
49 video_array_.push_back(video);
51 ++request_stream_counter_;
54 void MockMediaStreamDispatcher::CancelGenerateStream(
56 const base::WeakPtr<MediaStreamDispatcherEventHandler>& event_handler) {
57 EXPECT_EQ(request_id, request_id_);
60 void MockMediaStreamDispatcher::StopStreamDevice(
61 const StreamDeviceInfo& device_info) {
62 if (IsAudioMediaType(device_info.device.type)) {
63 ++stop_audio_device_counter_;
66 if (IsVideoMediaType(device_info.device.type)) {
67 ++stop_video_device_counter_;
73 bool MockMediaStreamDispatcher::IsStream(const std::string& label) {
77 int MockMediaStreamDispatcher::video_session_id(const std::string& label,
82 int MockMediaStreamDispatcher::audio_session_id(const std::string& label,
87 } // namespace content