| 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 "base/bind.h" | 5 #include "base/bind.h" |
| 6 #include "base/environment.h" | 6 #include "base/environment.h" |
| 7 #include "base/memory/scoped_ptr.h" | 7 #include "base/memory/scoped_ptr.h" |
| 8 #include "base/message_loop.h" | 8 #include "base/message_loop.h" |
| 9 #include "base/process_util.h" | 9 #include "base/process_util.h" |
| 10 #include "base/sync_socket.h" | 10 #include "base/sync_socket.h" |
| (...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 154 | 154 |
| 155 // Claim to be on both the UI and IO threads to pass all the DCHECKS. | 155 // Claim to be on both the UI and IO threads to pass all the DCHECKS. |
| 156 io_thread_.reset(new BrowserThreadImpl(BrowserThread::IO, | 156 io_thread_.reset(new BrowserThreadImpl(BrowserThread::IO, |
| 157 message_loop_.get())); | 157 message_loop_.get())); |
| 158 ui_thread_.reset(new BrowserThreadImpl(BrowserThread::UI, | 158 ui_thread_.reset(new BrowserThreadImpl(BrowserThread::UI, |
| 159 message_loop_.get())); | 159 message_loop_.get())); |
| 160 audio_manager_.reset(media::AudioManager::Create()); | 160 audio_manager_.reset(media::AudioManager::Create()); |
| 161 observer_.reset(new MockMediaObserver()); | 161 observer_.reset(new MockMediaObserver()); |
| 162 host_ = new MockAudioRendererHost(audio_manager_.get(), observer_.get()); | 162 host_ = new MockAudioRendererHost(audio_manager_.get(), observer_.get()); |
| 163 | 163 |
| 164 // Expect the audio stream will be deleted. |
| 165 EXPECT_CALL(*observer_, OnDeleteAudioStream(_, kStreamId)); |
| 166 |
| 164 // Simulate IPC channel connected. | 167 // Simulate IPC channel connected. |
| 165 host_->OnChannelConnected(base::GetCurrentProcId()); | 168 host_->OnChannelConnected(base::GetCurrentProcId()); |
| 166 } | 169 } |
| 167 | 170 |
| 168 virtual void TearDown() { | 171 virtual void TearDown() { |
| 169 // Simulate closing the IPC channel. | 172 // Simulate closing the IPC channel. |
| 170 host_->OnChannelClosing(); | 173 host_->OnChannelClosing(); |
| 171 | 174 |
| 172 // Release the reference to the mock object. The object will be destructed | 175 // Release the reference to the mock object. The object will be destructed |
| 173 // on message_loop_. | 176 // on message_loop_. |
| (...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 252 // Find the first AudioOutputController in the AudioRendererHost. | 255 // Find the first AudioOutputController in the AudioRendererHost. |
| 253 CHECK(host_->audio_entries_.size()) | 256 CHECK(host_->audio_entries_.size()) |
| 254 << "Calls Create() before calling this method"; | 257 << "Calls Create() before calling this method"; |
| 255 media::AudioOutputController* controller = | 258 media::AudioOutputController* controller = |
| 256 host_->audio_entries_.begin()->second->controller; | 259 host_->audio_entries_.begin()->second->controller; |
| 257 CHECK(controller) << "AudioOutputController not found"; | 260 CHECK(controller) << "AudioOutputController not found"; |
| 258 | 261 |
| 259 // Expect an error signal sent through IPC. | 262 // Expect an error signal sent through IPC. |
| 260 EXPECT_CALL(*host_, OnStreamError(kStreamId)); | 263 EXPECT_CALL(*host_, OnStreamError(kStreamId)); |
| 261 | 264 |
| 262 // Expect the audio stream will be deleted. | |
| 263 EXPECT_CALL(*observer_, OnDeleteAudioStream(_, kStreamId)); | |
| 264 | |
| 265 // Simulate an error sent from the audio device. | 265 // Simulate an error sent from the audio device. |
| 266 host_->OnError(controller, 0); | 266 host_->OnError(controller, 0); |
| 267 SyncWithAudioThread(); | 267 SyncWithAudioThread(); |
| 268 | 268 |
| 269 // Expect the audio stream record is removed. | 269 // Expect the audio stream record is removed. |
| 270 EXPECT_EQ(0u, host_->audio_entries_.size()); | 270 EXPECT_EQ(0u, host_->audio_entries_.size()); |
| 271 } | 271 } |
| 272 | 272 |
| 273 // Called on the audio thread. | 273 // Called on the audio thread. |
| 274 static void PostQuitMessageLoop(MessageLoop* message_loop) { | 274 static void PostQuitMessageLoop(MessageLoop* message_loop) { |
| (...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 392 EnableRealDevice(); | 392 EnableRealDevice(); |
| 393 | 393 |
| 394 Create(); | 394 Create(); |
| 395 Play(); | 395 Play(); |
| 396 SimulateError(); | 396 SimulateError(); |
| 397 Close(); | 397 Close(); |
| 398 } | 398 } |
| 399 | 399 |
| 400 | 400 |
| 401 // TODO(hclam): Add tests for data conversation in low latency mode. | 401 // TODO(hclam): Add tests for data conversation in low latency mode. |
| OLD | NEW |