Commit 0a647e67 authored by mflodman@chromium.org's avatar mflodman@chromium.org

Adding possibility to bypass MediaStream UI to be able to rununit tests on server.

Review URL: http://codereview.chromium.org/7314022

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@91824 0039d316-1c4b-4281-b951-d872f2087c98
parent 91a84b30
......@@ -38,7 +38,9 @@ struct MediaStreamDeviceSettings::SettingsRequest {
MediaStreamDeviceSettings::MediaStreamDeviceSettings(
SettingsRequester* requester)
: requester_(requester) {
: requester_(requester),
// TODO(macourteau) Change to false when UI exists.
use_fake_ui_(true) {
DCHECK(requester_);
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
}
......@@ -99,30 +101,38 @@ void MediaStreamDeviceSettings::AvailableDevices(
if (request->devices.size() == num_media_requests) {
// We have all answers needed.
// TODO(mflodman)
// This is the place to:
// - Choose what devices to use from some kind of settings, user dialog or
// default device.
// - Request user permission / show we're using devices.
// Temporary solution: pick first non-opened device for each media type.
StreamDeviceInfoArray devices_to_use;
for (DeviceMap::iterator it = request->devices.begin();
it != request->devices.end(); ++it) {
for (StreamDeviceInfoArray::iterator device_it = it->second.begin();
device_it != it->second.end(); ++device_it) {
if (!device_it->in_use) {
devices_to_use.push_back(*device_it);
break;
if (!use_fake_ui_) {
// TODO(macourteau)
// This is the place to:
// - Choose what devices to use from some kind of settings, user dialog or
// default device.
// - Request user permission / show we're using devices.
DCHECK(false);
} else {
// Used to fake UI, which is needed for server based testing.
// Choose first non-opened device for each media type.
StreamDeviceInfoArray devices_to_use;
for (DeviceMap::iterator it = request->devices.begin();
it != request->devices.end(); ++it) {
for (StreamDeviceInfoArray::iterator device_it = it->second.begin();
device_it != it->second.end(); ++device_it) {
if (!device_it->in_use) {
devices_to_use.push_back(*device_it);
break;
}
}
}
// Post result and delete request.
requester_->DevicesAccepted(label, devices_to_use);
requests_.erase(request_it);
delete request;
}
// Post result and delete request.
requester_->DevicesAccepted(label, devices_to_use);
requests_.erase(request_it);
delete request;
}
}
void MediaStreamDeviceSettings::UseFakeUI() {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
use_fake_ui_ = true;
}
} // namespace media_stream
......@@ -58,6 +58,11 @@ class MediaStreamDeviceSettings {
void AvailableDevices(const std::string& label, MediaStreamType stream_type,
const StreamDeviceInfoArray& devices);
// Used for testing only. This function is called to use faked UI, which is
// needed for server based tests. The first non-opened device(s) will be
// picked.
void UseFakeUI();
private:
struct SettingsRequest;
......@@ -66,6 +71,8 @@ class MediaStreamDeviceSettings {
typedef std::map<std::string, SettingsRequest*> SettingsRequests;
SettingsRequests requests_;
bool use_fake_ui_;
DISALLOW_COPY_AND_ASSIGN(MediaStreamDeviceSettings);
};
......
......@@ -355,6 +355,7 @@ void MediaStreamManager::SettingsError(const std::string& label) {
void MediaStreamManager::UseFakeDevice() {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
video_capture_manager_->UseFakeDevice();
device_settings_->UseFakeUI();
// TODO(mflodman) Add audio manager when available.
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment