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

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

Issue 1314803003: Include default communication devices in audio device enumerations. This removes heuristic that pic… (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Address comment Created 5 years, 3 months 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 <string> 5 #include <string>
6 6
7 #include "base/memory/ref_counted.h" 7 #include "base/memory/ref_counted.h"
8 #include "base/memory/scoped_ptr.h" 8 #include "base/memory/scoped_ptr.h"
9 #include "base/message_loop/message_loop.h" 9 #include "base/message_loop/message_loop.h"
10 #include "base/strings/string_number_conversions.h" 10 #include "base/strings/string_number_conversions.h"
(...skipping 387 matching lines...) Expand 10 before | Expand all | Expand 10 after
398 398
399 dispatcher_->OnMessageReceived( 399 dispatcher_->OnMessageReceived(
400 MediaStreamMsg_DeviceStopped(kRouteId, label, handler_->video_device_)); 400 MediaStreamMsg_DeviceStopped(kRouteId, label, handler_->video_device_));
401 // Verify that MediaStreamDispatcherEventHandler::OnDeviceStopped has been 401 // Verify that MediaStreamDispatcherEventHandler::OnDeviceStopped has been
402 // called. 402 // called.
403 EXPECT_EQ(label, handler_->device_stopped_label_); 403 EXPECT_EQ(label, handler_->device_stopped_label_);
404 EXPECT_EQ(dispatcher_->video_session_id(label, 0), 404 EXPECT_EQ(dispatcher_->video_session_id(label, 0),
405 StreamDeviceInfo::kNoId); 405 StreamDeviceInfo::kNoId);
406 } 406 }
407 407
408 TEST_F(MediaStreamDispatcherTest, CheckDuckingState) {
409 scoped_ptr<MediaStreamDispatcher> dispatcher(new MediaStreamDispatcher(NULL));
410 scoped_ptr<MockMediaStreamDispatcherEventHandler>
411 handler(new MockMediaStreamDispatcherEventHandler);
412 StreamOptions components(true, false); // audio only.
413 int ipc_request_id1 = dispatcher->next_ipc_id_;
414
415 dispatcher->GenerateStream(kRequestId1, handler.get()->AsWeakPtr(),
416 components, GURL());
417 EXPECT_EQ(1u, dispatcher->requests_.size());
418
419 // Ducking isn't active at this point.
420 EXPECT_FALSE(dispatcher->IsAudioDuckingActive());
421
422 // Complete the creation of stream1 with a single audio track that has
423 // ducking enabled.
424 StreamDeviceInfoArray audio_device_array(1);
425 StreamDeviceInfo& audio_device_info = audio_device_array[0];
426 audio_device_info.device.name = "Microphone";
427 audio_device_info.device.type = kAudioType;
428 audio_device_info.session_id = kAudioSessionId;
429 audio_device_info.device.input.effects = media::AudioParameters::DUCKING;
430
431 StreamDeviceInfoArray video_device_array; // Empty for this test.
432
433 const char kStreamLabel[] = "stream1";
434 dispatcher->OnMessageReceived(MediaStreamMsg_StreamGenerated(
435 kRouteId, ipc_request_id1, kStreamLabel,
436 audio_device_array, video_device_array));
437 EXPECT_EQ(handler->request_id_, kRequestId1);
438 EXPECT_EQ(0u, dispatcher->requests_.size());
439
440 // Ducking should now be reported as active.
441 EXPECT_TRUE(dispatcher->IsAudioDuckingActive());
442
443 // Stop the device (removes the stream).
444 dispatcher->OnMessageReceived(
445 MediaStreamMsg_DeviceStopped(kRouteId, kStreamLabel,
446 handler->audio_device_));
447
448 // Ducking should now be reported as inactive again.
449 EXPECT_FALSE(dispatcher->IsAudioDuckingActive());
450
451 // Now do the same sort of test with the DUCKING flag off.
452 audio_device_info.device.input.effects =
453 media::AudioParameters::ECHO_CANCELLER;
454
455 dispatcher->OnMessageReceived(MediaStreamMsg_StreamGenerated(
456 kRouteId, ipc_request_id1, kStreamLabel,
457 audio_device_array, video_device_array));
458 EXPECT_EQ(handler->request_id_, kRequestId1);
459 EXPECT_EQ(0u, dispatcher->requests_.size());
460
461 // Ducking should still be reported as not active.
462 EXPECT_FALSE(dispatcher->IsAudioDuckingActive());
463
464 // Stop the device (removes the stream).
465 dispatcher->OnMessageReceived(
466 MediaStreamMsg_DeviceStopped(kRouteId, kStreamLabel,
467 handler->audio_device_));
468 }
469
470 } // namespace content 408 } // namespace content
OLDNEW
« no previous file with comments | « content/renderer/media/media_stream_dispatcher.cc ('k') | content/renderer/media/webrtc/peer_connection_dependency_factory.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698