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

Side by Side Diff: content/browser/renderer_host/media/audio_input_device_manager_unittest.cc

Issue 9805001: Move media/audio files into media namespace (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 8 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 | Annotate | Revision Log
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/bind.h" 7 #include "base/bind.h"
8 #include "base/memory/ref_counted.h" 8 #include "base/memory/ref_counted.h"
9 #include "base/memory/scoped_ptr.h" 9 #include "base/memory/scoped_ptr.h"
10 #include "base/message_loop.h" 10 #include "base/message_loop.h"
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after
98 bool CanRunAudioInputDeviceTests() { 98 bool CanRunAudioInputDeviceTests() {
99 return audio_manager_->HasAudioInputDevices(); 99 return audio_manager_->HasAudioInputDevices();
100 } 100 }
101 101
102 protected: 102 protected:
103 virtual void SetUp() { 103 virtual void SetUp() {
104 // The test must run on Browser::IO. 104 // The test must run on Browser::IO.
105 message_loop_.reset(new MessageLoop(MessageLoop::TYPE_IO)); 105 message_loop_.reset(new MessageLoop(MessageLoop::TYPE_IO));
106 io_thread_.reset(new BrowserThreadImpl(BrowserThread::IO, 106 io_thread_.reset(new BrowserThreadImpl(BrowserThread::IO,
107 message_loop_.get())); 107 message_loop_.get()));
108 audio_manager_.reset(AudioManager::Create()); 108 audio_manager_.reset(media::AudioManager::Create());
109 109
110 manager_ = new AudioInputDeviceManager(audio_manager_.get()); 110 manager_ = new AudioInputDeviceManager(audio_manager_.get());
111 audio_input_listener_.reset(new MockAudioInputDeviceManagerListener()); 111 audio_input_listener_.reset(new MockAudioInputDeviceManagerListener());
112 manager_->Register(audio_input_listener_.get()); 112 manager_->Register(audio_input_listener_.get());
113 113
114 // Gets the enumerated device list from the AudioInputDeviceManager. 114 // Gets the enumerated device list from the AudioInputDeviceManager.
115 manager_->EnumerateDevices(); 115 manager_->EnumerateDevices();
116 EXPECT_CALL(*audio_input_listener_, DevicesEnumerated(_)) 116 EXPECT_CALL(*audio_input_listener_, DevicesEnumerated(_))
117 .Times(1); 117 .Times(1);
118 118
119 // Waits for the callback. 119 // Waits for the callback.
120 message_loop_->RunAllPending(); 120 message_loop_->RunAllPending();
121 } 121 }
122 122
123 virtual void TearDown() { 123 virtual void TearDown() {
124 manager_->Unregister(); 124 manager_->Unregister();
125 io_thread_.reset(); 125 io_thread_.reset();
126 } 126 }
127 127
128 scoped_ptr<MessageLoop> message_loop_; 128 scoped_ptr<MessageLoop> message_loop_;
129 scoped_ptr<BrowserThreadImpl> io_thread_; 129 scoped_ptr<BrowserThreadImpl> io_thread_;
130 scoped_refptr<AudioInputDeviceManager> manager_; 130 scoped_refptr<AudioInputDeviceManager> manager_;
131 scoped_ptr<MockAudioInputDeviceManagerListener> audio_input_listener_; 131 scoped_ptr<MockAudioInputDeviceManagerListener> audio_input_listener_;
132 scoped_ptr<AudioManager> audio_manager_; 132 scoped_ptr<media::AudioManager> audio_manager_;
133 133
134 private: 134 private:
135 DISALLOW_COPY_AND_ASSIGN(AudioInputDeviceManagerTest); 135 DISALLOW_COPY_AND_ASSIGN(AudioInputDeviceManagerTest);
136 }; 136 };
137 137
138 // Opens and closes the devices. 138 // Opens and closes the devices.
139 TEST_F(AudioInputDeviceManagerTest, OpenAndCloseDevice) { 139 TEST_F(AudioInputDeviceManagerTest, OpenAndCloseDevice) {
140 if (!CanRunAudioInputDeviceTests()) 140 if (!CanRunAudioInputDeviceTests())
141 return; 141 return;
142 142
(...skipping 264 matching lines...) Expand 10 before | Expand all | Expand 10 after
407 Opened(content::MEDIA_STREAM_DEVICE_TYPE_AUDIO_CAPTURE, 407 Opened(content::MEDIA_STREAM_DEVICE_TYPE_AUDIO_CAPTURE,
408 second_session_id)) 408 second_session_id))
409 .Times(1); 409 .Times(1);
410 message_loop_->RunAllPending(); 410 message_loop_->RunAllPending();
411 411
412 // Calls Start()/Stop()/Close() for the default device twice. 412 // Calls Start()/Stop()/Close() for the default device twice.
413 manager_->Start(first_session_id, first_event_handler.get()); 413 manager_->Start(first_session_id, first_event_handler.get());
414 manager_->Start(second_session_id, second_event_handler.get()); 414 manager_->Start(second_session_id, second_event_handler.get());
415 EXPECT_CALL(*first_event_handler, 415 EXPECT_CALL(*first_event_handler,
416 DeviceStarted(first_session_id, 416 DeviceStarted(first_session_id,
417 AudioManagerBase::kDefaultDeviceId)) 417 media::AudioManagerBase::kDefaultDeviceId))
418 .Times(1); 418 .Times(1);
419 EXPECT_CALL(*second_event_handler, 419 EXPECT_CALL(*second_event_handler,
420 DeviceStarted(second_session_id, 420 DeviceStarted(second_session_id,
421 AudioManagerBase::kDefaultDeviceId)) 421 media::AudioManagerBase::kDefaultDeviceId))
422 .Times(1); 422 .Times(1);
423 message_loop_->RunAllPending(); 423 message_loop_->RunAllPending();
424 424
425 manager_->Stop(first_session_id); 425 manager_->Stop(first_session_id);
426 manager_->Stop(second_session_id); 426 manager_->Stop(second_session_id);
427 manager_->Close(first_session_id); 427 manager_->Close(first_session_id);
428 manager_->Close(second_session_id); 428 manager_->Close(second_session_id);
429 EXPECT_CALL(*audio_input_listener_, 429 EXPECT_CALL(*audio_input_listener_,
430 Closed(content::MEDIA_STREAM_DEVICE_TYPE_AUDIO_CAPTURE, 430 Closed(content::MEDIA_STREAM_DEVICE_TYPE_AUDIO_CAPTURE,
431 first_session_id)) 431 first_session_id))
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
495 EXPECT_CALL(*audio_input_listener_, 495 EXPECT_CALL(*audio_input_listener_,
496 Opened(content::MEDIA_STREAM_DEVICE_TYPE_AUDIO_CAPTURE, 496 Opened(content::MEDIA_STREAM_DEVICE_TYPE_AUDIO_CAPTURE,
497 session_id)) 497 session_id))
498 .Times(1); 498 .Times(1);
499 message_loop_->RunAllPending(); 499 message_loop_->RunAllPending();
500 500
501 // Starts the session, it should succeed. 501 // Starts the session, it should succeed.
502 manager_->Start(session_id, audio_input_event_handler.get()); 502 manager_->Start(session_id, audio_input_event_handler.get());
503 EXPECT_CALL(*audio_input_event_handler, 503 EXPECT_CALL(*audio_input_event_handler,
504 DeviceStarted(session_id, 504 DeviceStarted(session_id,
505 AudioManagerBase::kDefaultDeviceId)) 505 media::AudioManagerBase::kDefaultDeviceId))
506 .Times(1); 506 .Times(1);
507 message_loop_->RunAllPending(); 507 message_loop_->RunAllPending();
508 508
509 // Starts the session for the second time, it should fail. 509 // Starts the session for the second time, it should fail.
510 manager_->Start(session_id, audio_input_event_handler.get()); 510 manager_->Start(session_id, audio_input_event_handler.get());
511 EXPECT_CALL(*audio_input_event_handler, 511 EXPECT_CALL(*audio_input_event_handler,
512 DeviceStarted(session_id, 512 DeviceStarted(session_id,
513 AudioInputDeviceManager::kInvalidDeviceId)) 513 AudioInputDeviceManager::kInvalidDeviceId))
514 .Times(1); 514 .Times(1);
515 515
516 manager_->Stop(session_id); 516 manager_->Stop(session_id);
517 manager_->Close(session_id); 517 manager_->Close(session_id);
518 EXPECT_CALL(*audio_input_listener_, 518 EXPECT_CALL(*audio_input_listener_,
519 Closed(content::MEDIA_STREAM_DEVICE_TYPE_AUDIO_CAPTURE, 519 Closed(content::MEDIA_STREAM_DEVICE_TYPE_AUDIO_CAPTURE,
520 session_id)) 520 session_id))
521 .Times(1); 521 .Times(1);
522 message_loop_->RunAllPending(); 522 message_loop_->RunAllPending();
523 } 523 }
524 524
525 } // namespace media_stream 525 } // namespace media_stream
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698