Chromium Code Reviews| OLD | NEW |
|---|---|
| 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" |
| 11 #include "content/common/media/media_stream_messages.h" | 11 #include "content/common/media/media_stream_messages.h" |
| 12 #include "content/public/common/media_stream_request.h" | 12 #include "content/public/common/media_stream_request.h" |
| 13 #include "content/renderer/media/media_stream_dispatcher.h" | 13 #include "content/renderer/media/media_stream_dispatcher.h" |
| 14 #include "content/renderer/media/media_stream_dispatcher_eventhandler.h" | 14 #include "content/renderer/media/media_stream_dispatcher_eventhandler.h" |
| 15 #include "media/audio/audio_parameters.h" | |
| 15 #include "testing/gtest/include/gtest/gtest.h" | 16 #include "testing/gtest/include/gtest/gtest.h" |
| 16 #include "url/gurl.h" | 17 #include "url/gurl.h" |
| 17 | 18 |
| 18 namespace content { | 19 namespace content { |
| 19 namespace { | 20 namespace { |
| 20 | 21 |
| 21 const int kRouteId = 0; | 22 const int kRouteId = 0; |
| 22 const int kAudioSessionId = 3; | 23 const int kAudioSessionId = 3; |
| 23 const int kVideoSessionId = 5; | 24 const int kVideoSessionId = 5; |
| 24 const int kRequestId1 = 10; | 25 const int kRequestId1 = 10; |
| (...skipping 378 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 403 | 404 |
| 404 dispatcher_->OnMessageReceived( | 405 dispatcher_->OnMessageReceived( |
| 405 MediaStreamMsg_DeviceStopped(kRouteId, label, handler_->video_device_)); | 406 MediaStreamMsg_DeviceStopped(kRouteId, label, handler_->video_device_)); |
| 406 // Verify that MediaStreamDispatcherEventHandler::OnDeviceStopped has been | 407 // Verify that MediaStreamDispatcherEventHandler::OnDeviceStopped has been |
| 407 // called. | 408 // called. |
| 408 EXPECT_EQ(label, handler_->device_stopped_label_); | 409 EXPECT_EQ(label, handler_->device_stopped_label_); |
| 409 EXPECT_EQ(dispatcher_->video_session_id(label, 0), | 410 EXPECT_EQ(dispatcher_->video_session_id(label, 0), |
| 410 StreamDeviceInfo::kNoId); | 411 StreamDeviceInfo::kNoId); |
| 411 } | 412 } |
| 412 | 413 |
| 414 TEST_F(MediaStreamDispatcherTest, CheckDuckingState) { | |
| 415 scoped_ptr<MediaStreamDispatcher> dispatcher(new MediaStreamDispatcher(NULL)); | |
| 416 scoped_ptr<MockMediaStreamDispatcherEventHandler> | |
| 417 handler(new MockMediaStreamDispatcherEventHandler); | |
| 418 StreamOptions components(true, false); // audio only. | |
| 419 int ipc_request_id1 = dispatcher->next_ipc_id_; | |
| 420 | |
| 421 dispatcher->GenerateStream(kRequestId1, handler.get()->AsWeakPtr(), | |
| 422 components, GURL()); | |
| 423 EXPECT_EQ(1u, dispatcher->requests_.size()); | |
| 424 | |
| 425 // Ducking isn't active at this point. | |
| 426 EXPECT_FALSE(dispatcher->IsAudioDuckingActive()); | |
| 427 | |
| 428 // Complete the creation of stream1 with a single audio track that has | |
| 429 // ducking enabled. | |
| 430 StreamDeviceInfoArray audio_device_array(1); | |
| 431 StreamDeviceInfo& audio_device_info = audio_device_array[0]; | |
| 432 audio_device_info.device.name = "Microphone"; | |
| 433 audio_device_info.device.type = kAudioType; | |
| 434 audio_device_info.session_id = kAudioSessionId; | |
| 435 audio_device_info.device.input.effects = media::AudioParameters::DUCKING; | |
|
no longer working on chromium
2014/07/08 10:42:35
do you mind adding a few lines of code to check du
tommi (sloooow) - chröme
2014/07/08 12:30:56
I think that's a good idea given my blunder in the
| |
| 436 | |
| 437 StreamDeviceInfoArray video_device_array; // Empty for this test. | |
| 438 | |
| 439 const char kStreamLabel[] = "stream1"; | |
| 440 dispatcher->OnMessageReceived(MediaStreamMsg_StreamGenerated( | |
| 441 kRouteId, ipc_request_id1, kStreamLabel, | |
| 442 audio_device_array, video_device_array)); | |
| 443 EXPECT_EQ(handler->request_id_, kRequestId1); | |
| 444 EXPECT_EQ(0u, dispatcher->requests_.size()); | |
| 445 | |
| 446 // Ducking should now be reported as active. | |
| 447 EXPECT_TRUE(dispatcher->IsAudioDuckingActive()); | |
| 448 | |
| 449 // Stop the device (removes the stream). | |
| 450 dispatcher->OnMessageReceived( | |
| 451 MediaStreamMsg_DeviceStopped(kRouteId, kStreamLabel, | |
| 452 handler->audio_device_)); | |
| 453 | |
| 454 // Ducking should now be reported as inactive again. | |
| 455 EXPECT_FALSE(dispatcher->IsAudioDuckingActive()); | |
| 456 } | |
| 457 | |
| 413 } // namespace content | 458 } // namespace content |
| OLD | NEW |