mock_media_stream_dispatcher.cc revision 2a99a7e74a7f215066514fe81d2bfa6639d9eddd
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. 4 5#include "content/renderer/media/mock_media_stream_dispatcher.h" 6 7#include "base/stringprintf.h" 8#include "content/public/common/media_stream_request.h" 9#include "testing/gtest/include/gtest/gtest.h" 10 11namespace content { 12 13MockMediaStreamDispatcher::MockMediaStreamDispatcher() 14 : MediaStreamDispatcher(NULL), 15 request_id_(-1), 16 request_stream_counter_(0), 17 stop_stream_counter_(0) { 18} 19 20MockMediaStreamDispatcher::~MockMediaStreamDispatcher() {} 21 22void MockMediaStreamDispatcher::GenerateStream( 23 int request_id, 24 const base::WeakPtr<MediaStreamDispatcherEventHandler>& event_handler, 25 const StreamOptions& components, 26 const GURL& url) { 27 request_id_ = request_id; 28 29 stream_label_ = base::StringPrintf("%s%d","local_stream",request_id); 30 audio_array_.clear(); 31 video_array_.clear(); 32 33 if (IsAudioMediaType(components.audio_type)) { 34 StreamDeviceInfo audio; 35 audio.device.id = "audio_device_id"; 36 audio.device.name = "microphone"; 37 audio.device.type = components.audio_type; 38 audio.session_id = request_id; 39 audio_array_.push_back(audio); 40 } 41 if (IsVideoMediaType(components.video_type)) { 42 StreamDeviceInfo video; 43 video.device.id = "video_device_id"; 44 video.device.name = "usb video camera"; 45 video.device.type = components.video_type; 46 video.session_id = request_id; 47 video_array_.push_back(video); 48 } 49 ++request_stream_counter_; 50} 51 52void MockMediaStreamDispatcher::CancelGenerateStream(int request_id) { 53 EXPECT_EQ(request_id, request_id_); 54} 55 56void MockMediaStreamDispatcher::StopStream(const std::string& label) { 57 ++stop_stream_counter_; 58} 59 60bool MockMediaStreamDispatcher::IsStream(const std::string& label) { 61 return true; 62} 63 64int MockMediaStreamDispatcher::video_session_id(const std::string& label, 65 int index) { 66 return -1; 67} 68 69int MockMediaStreamDispatcher::audio_session_id(const std::string& label, 70 int index) { 71 return -1; 72} 73 74} // namespace content 75