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 { ...@@ -38,7 +38,9 @@ struct MediaStreamDeviceSettings::SettingsRequest {
MediaStreamDeviceSettings::MediaStreamDeviceSettings( MediaStreamDeviceSettings::MediaStreamDeviceSettings(
SettingsRequester* requester) SettingsRequester* requester)
: requester_(requester) { : requester_(requester),
// TODO(macourteau) Change to false when UI exists.
use_fake_ui_(true) {
DCHECK(requester_); DCHECK(requester_);
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
} }
...@@ -99,30 +101,38 @@ void MediaStreamDeviceSettings::AvailableDevices( ...@@ -99,30 +101,38 @@ void MediaStreamDeviceSettings::AvailableDevices(
if (request->devices.size() == num_media_requests) { if (request->devices.size() == num_media_requests) {
// We have all answers needed. // We have all answers needed.
if (!use_fake_ui_) {
// TODO(mflodman) // TODO(macourteau)
// This is the place to: // This is the place to:
// - Choose what devices to use from some kind of settings, user dialog or // - Choose what devices to use from some kind of settings, user dialog or
// default device. // default device.
// - Request user permission / show we're using devices. // - Request user permission / show we're using devices.
DCHECK(false);
// Temporary solution: pick first non-opened device for each media type. } else {
StreamDeviceInfoArray devices_to_use; // Used to fake UI, which is needed for server based testing.
for (DeviceMap::iterator it = request->devices.begin(); // Choose first non-opened device for each media type.
it != request->devices.end(); ++it) { StreamDeviceInfoArray devices_to_use;
for (StreamDeviceInfoArray::iterator device_it = it->second.begin(); for (DeviceMap::iterator it = request->devices.begin();
device_it != it->second.end(); ++device_it) { it != request->devices.end(); ++it) {
if (!device_it->in_use) { for (StreamDeviceInfoArray::iterator device_it = it->second.begin();
devices_to_use.push_back(*device_it); device_it != it->second.end(); ++device_it) {
break; 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 } // namespace media_stream
...@@ -58,6 +58,11 @@ class MediaStreamDeviceSettings { ...@@ -58,6 +58,11 @@ class MediaStreamDeviceSettings {
void AvailableDevices(const std::string& label, MediaStreamType stream_type, void AvailableDevices(const std::string& label, MediaStreamType stream_type,
const StreamDeviceInfoArray& devices); 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: private:
struct SettingsRequest; struct SettingsRequest;
...@@ -66,6 +71,8 @@ class MediaStreamDeviceSettings { ...@@ -66,6 +71,8 @@ class MediaStreamDeviceSettings {
typedef std::map<std::string, SettingsRequest*> SettingsRequests; typedef std::map<std::string, SettingsRequest*> SettingsRequests;
SettingsRequests requests_; SettingsRequests requests_;
bool use_fake_ui_;
DISALLOW_COPY_AND_ASSIGN(MediaStreamDeviceSettings); DISALLOW_COPY_AND_ASSIGN(MediaStreamDeviceSettings);
}; };
......
...@@ -355,6 +355,7 @@ void MediaStreamManager::SettingsError(const std::string& label) { ...@@ -355,6 +355,7 @@ void MediaStreamManager::SettingsError(const std::string& label) {
void MediaStreamManager::UseFakeDevice() { void MediaStreamManager::UseFakeDevice() {
DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO)); DCHECK(BrowserThread::CurrentlyOn(BrowserThread::IO));
video_capture_manager_->UseFakeDevice(); video_capture_manager_->UseFakeDevice();
device_settings_->UseFakeUI();
// TODO(mflodman) Add audio manager when available. // 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