Index: content/renderer/media/audio_device_unittest.cc |
diff --git a/content/renderer/media/audio_device_unittest.cc b/content/renderer/media/audio_device_unittest.cc |
index adf5506cca2b3b5d45e0a65acf1be1b993e43d46..e1b71e2fc5e4f1451c77cc6ac236f9d56ca7528e 100644 |
--- a/content/renderer/media/audio_device_unittest.cc |
+++ b/content/renderer/media/audio_device_unittest.cc |
@@ -111,6 +111,19 @@ ACTION_P(QuitLoop, loop) { |
loop->PostTask(FROM_HERE, MessageLoop::QuitClosure()); |
} |
+// Zeros out all the buffers in the |audio_data| vector. |
+void FillData(const std::vector<float*>& audio_data, |
+ int number_of_frames, |
henrika (OOO until Aug 14)
2012/07/23 11:17:07
Odd indentation. int is not aligned with const.
tommi (sloooow) - chröme
2012/07/23 12:23:10
Done.
|
+ int audio_delay_milliseconds) { |
+ std::vector<float*>::const_iterator it = audio_data.begin(); |
+ for (; it != audio_data.end(); ++it) { |
+ float* channel = *it; |
+ for (int j = 0; j < number_of_frames; ++j) { |
+ channel[j] = 0.0f; |
+ } |
+ } |
+} |
+ |
} // namespace. |
class AudioDeviceTest : public testing::Test { |
@@ -197,7 +210,9 @@ TEST_F(AudioDeviceTest, CreateStream) { |
int memory_size = media::TotalSharedMemorySizeInBytes( |
default_audio_parameters_.GetBytesPerBuffer()); |
SharedMemory shared_memory; |
- ASSERT_TRUE(shared_memory.CreateAnonymous(memory_size)); |
+ ASSERT_TRUE(shared_memory.CreateAndMapAnonymous(memory_size)); |
+ // Initialize the memory. |
+ memset(shared_memory.memory(), 0xff, memory_size); |
CancelableSyncSocket browser_socket, renderer_socket; |
ASSERT_TRUE(CancelableSyncSocket::CreatePair(&browser_socket, |
@@ -228,6 +243,7 @@ TEST_F(AudioDeviceTest, CreateStream) { |
// of success and quit the loop. |
EXPECT_CALL(callback_, Render(_, _, _)) |
.WillOnce(DoAll( |
+ WithArgs<0, 1, 2>(Invoke(&FillData)), |
henrika (OOO until Aug 14)
2012/07/23 11:17:07
Mind adding a comment?
tommi (sloooow) - chröme
2012/07/23 12:23:10
Done.
|
QuitLoop(io_loop_.message_loop_proxy()), |
Return(1))); |
henrika (OOO until Aug 14)
2012/07/23 11:17:07
Why 1 here?
|